Copied to clipboard

Flag this post as spam?

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


  • Melanie Rohr 7 posts 28 karma points
    Sep 12, 2016 @ 21:20
    Melanie Rohr
    0

    filtering by checkbox U4.11

    I'm trying to filter a list of projects by categories from a checkbox data type list. Is this possible by just filtering through by text value of the checked item? I've done something similar in the past with radio buttons where (filtered by prevalues actually) but the same code doesn't seem to work for checkboxes. Been running in circles trying to get this work so any help is greatly appreciated. Thx!

    var projects = Model.AncestorOrSelf().Descendants("projectDocType");
    
    foreach(var item in projects.Where("Category.ToString().Contains(\"CategoryTextToFilter\")"))   
        {               
            <p><a href="@item.Url">@item.Name</a></p>           
        }
    
  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Sep 14, 2016 @ 16:35
    Alex Skrypnyk
    0

    Hi Melanie,

    It looks like you need to use id of "CategoryTextToFilter", becaue field is storing id of string, not text.

    Thanks,

    Alex

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Sep 22, 2016 @ 20:06
    Alex Skrypnyk
    0

    Hi Melanie,

    Did you find solution?

  • Melanie Rohr 7 posts 28 karma points
    Sep 22, 2016 @ 21:47
    Melanie Rohr
    1

    Hi Alex,

    Yes, thanks for checking, I sort of got it to work like so:

    foreach(var item in projects.Where("visible")) 
    {   
        var chked = @item.Category.ToString(); 
        if(chked.Contains("CategoryText")){ 
            <p><a href="@item.Url">@item.Name</a></p> 
        }
    
    }
    

    Using Id like you suggested didn't work for me unfortunately. I think that only works with the radiobutton data type.

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Sep 23, 2016 @ 10:20
    Alex Skrypnyk
    0

    Glad that this topic is solved!

    Have a good day, thanks for sharing code!!!

Please Sign in or register to post replies

Write your reply to:

Draft