Copied to clipboard

Flag this post as spam?

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


  • Mr A 216 posts 278 karma points
    Jun 08, 2012 @ 14:52
    Mr A
    0

    Using WHERE to perform filteration on radio button list

    Hi ,

    I have got a radiobuttonlist [apple,banana,mangoe]on which i have to perform filteration to display result , below is the code :

    @inherits umbraco.MacroEngines.DynamicNodeContext
    <div id="right-col">
            <h2>
                list of products</h2>

    @foreach (var item in @Model.NodeById(1302).Children.Where("productType == \"apple\""))
    {
        <div class="testimonial">
       
             <p>
               
                    @item.productContent
              </p>
               </div>
                     
        }
    </div>

    The above code is not working , what i want to display is the list of selected product

    from radiobutton list, so for instance if apple is selected , only apple products

    with details should be displayed, any suggestions where iam getting it wrong

  • Kasper Dyrvig 246 posts 379 karma points
    Jun 11, 2012 @ 12:04
    Kasper Dyrvig
    0

    I don't have a suggestion right away, but could you give some more info on how the content is structured?

    Do you want to view products that has the propertyType "Apple"?

  • Grant Thomas 291 posts 324 karma points
    Jun 11, 2012 @ 14:06
    Grant Thomas
    0

    Are product types immediately under the specified node, or structured in to categorised folders?

    Using `Descendants` should help in this case, if you're careful.

    @foreach (var item in @Model.NodeById(1302).Descendants.Where("productType == \"apple\""))

  • Mr A 216 posts 278 karma points
    Jun 11, 2012 @ 14:15
    Mr A
    0

    well the tree is like :

    Products

    product1[radio button list(property) of apple,banana,apricot]

    product2[radio button list(property) of apple,banana,apricot] .....

    Now the issue is i want to display these products on different pages and i want to filter it withrespect to the selected radio button list from the backend, so for instance if product 1 has a selected property of apple , then it comes under page 1 , similarly if the selected property of product 2 is banana , then it will be displayed on page 2 , hope it makes sense.

  • Kasper Dyrvig 246 posts 379 karma points
    Jun 13, 2012 @ 08:46
    Kasper Dyrvig
    0

    Okay.

    I assume that your products pages have their own document type. If not, you need to hardcode the parentId for the product pages.

    The following is not tested.

    @inherits umbraco.MacroEngines.DynamicNodeContext
    @*First look for a parameter in the macro so we know what producttype to look for*@
    @{
    var pt = Parameter.Level;
    <ul>
    @foreach(var product in Model.Descendants.Where("productType == pt"))
    {
    <li>@product.Name</li>
    }
    </ul>
    }

    How does that work? :-)

  • 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