Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Libin Joseph 9 posts 31 karma points
    Oct 02, 2013 @ 19:07
    Libin Joseph
    0

    Filter contents in relation to value selected from a drop down box

    I want to filter a list of contents based on the values selected in a drop down box. 

    This is my workflow.

    When the page loads, it displays a list of fruits.

    There will a drop down box at the top of the page which says Color. And I would select "red" and hit update.

    That should clear the list below and show all fruits, which are of color "Red"

    Note: Each of these fruits will have a seperate property called color. Which I have not listed, But I know we are filtereing on that property.

     

    How can I achieve this? 

    I hope its something similar to this:

    <ul>
    @foreach(var item in @Model.Children.Where("Red"))
    {
        <li>@item.Name</li>
    }
    </ul>
    My biggest concern is how do i pass the value red here on a button click. I hope I am on the right path.

     

  • Jeavon Leopold 3008 posts 13221 karma points MVP 7x admin c-trib
    Oct 02, 2013 @ 22:14
    Jeavon Leopold
    0

    Hi again,

    Are you wanting to perform this filtering asynchronously with JavaScript or are you thinking the page will reload?

    For a asynchronous solution if you are using Umbraco v6.1 the recommended approach is to use UmbracoApi Controller There is a very good blog post here also.

    If you are using a older version of Umbraco and cannot upgrade then the approach is to use the /base Api

    You will of course need some jQuery or other JS Ajax handler to request the data and decide if you do the filtering client side or have a parameter you pass with the request and make a Ajax request each time the filter is changed.

    If you are looking for a classic querystring/page reload solution have a look at this thread which is very similar.

    Thanks,

    Jeavon

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies