On Demand Filtering

8 posts, 0 answers
  1. Michael Murphy
    Michael Murphy avatar
    2 posts
    Member since:
    Sep 2009

    Posted 13 Jul 2011 Link to this post

    I am new to the WinForms components and here is what I would like to be able to do. Not sure if this functionality is built in or if I will need to use a combination of Telerik controls so I figured it would be faster to ask. :)

    I want to be able to fill a listview... then have a way to type in criteria and have it filter the listview accordingly. I want to be able to use checkboxes so once I have the listview filtered I can select certain items using the checkboxes.

    Then I want to be able to remove the criteria and the listview restores all the items while retaining the items with checks in the checkboxes. Then i'll enter new criteria, which filters the list, i select more items via the checkboxes, remove the criteria, selected items are retained and so on...

    Please let me know how to do this. :)
  2. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 15 Jul 2011 Link to this post

    Hello Michael,

    Thank you for your question.

    Yes, this can be easily achieved using RadListView. It supports built-in checkboxes and filtering via filter descriptors. Below is a sample code that implements the mentioned requirements. It assumes using a RadListView and a RadTextBox.
    public partial class Form30 : Form
    {
        public Form30()
        {
            InitializeComponent();
            this.radListView1.ShowCheckBoxes = true;
        }
     
        private void radTextBox1_TextChanged(object sender, EventArgs e)
        {
            this.radListView1.FilterDescriptors.Clear();
     
            if (this.radTextBox1.Text.Length > 0)
            {
                this.radListView1.FilterDescriptors.Add(new FilterDescriptor("Value", FilterOperator.Contains, this.radTextBox1.Text));
                this.radListView1.EnableFiltering = true;
            }
            else
            {
                this.radListView1.EnableFiltering = false;
            }
        }
    }

    More information about RadListView can be found in its corresponding help section.

    I hope this was useful. Do not hesitate to contact me if you need further assistance.

    All the best,
    Ivan Todorov
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. UI for WinForms is Visual Studio 2017 Ready
  4. Michael Murphy
    Michael Murphy avatar
    2 posts
    Member since:
    Sep 2009

    Posted 15 Jul 2011 Link to this post

    AWESOME! Works perfectly! Thanks for saving me time!
  5. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 20 Jul 2011 Link to this post

    Hello Michael,

    I am glad I could help.

    Feel free to share with us your feedback on this new control or contact us whenever you need assistance. We are always ready to help you.

    Best wishes,
    Ivan Todorov
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  6. RR
    RR avatar
    2 posts
    Member since:
    Jan 2012

    Posted 20 Jan 2012 Link to this post

    Hi,

    What if I wan to use multiple filter criteria?

    For Example: Lets say I have two List Views with ShowCheckBoxes set to True
    .
    ListView1 with items Type1, Type 2 Type 3
    And  ListView2 with Items T11, T12, T13, T21,T22, T23, T31. T32,T33

    When I Select Type1 in ListView1, then I need to Show the items T11, T12, T13  only in ListView2
    Similerly when I select Type2 then T21,T22, T23 needs to be shown and same as the case for Type3

    I'm able achieve this behavior by adding the Filter.

    Now the it is required to show T11, T12, T13, T21,T22, T23  items When both Type1 and Type2 are selected.

    I Tried to achieve this by adding multiple FilterDescriptors but of no use. 

    Is this feature supported by ListView filtering? If yes, please explain me how to achieve.

    Thanks.




  7. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 25 Jan 2012 Link to this post

    Hi RR,

    You can use the CompositeFilterDescriptor to achieve this. The following code snippet demonstrates this:

    private void radListView1_ItemCheckedChanged(object sender, Telerik.WinControls.UI.ListViewItemEventArgs e)
    {
        CompositeFilterDescriptor des = new CompositeFilterDescriptor();
        des.LogicalOperator = FilterLogicalOperator.Or;
     
        if (this.radListView1.Items[0].CheckState == ToggleState.On)
        {
            des.FilterDescriptors.Add(new FilterDescriptor("Text", FilterOperator.StartsWith, "T1"));
        }
        if (this.radListView1.Items[1].CheckState == ToggleState.On)
        {
            des.FilterDescriptors.Add(new FilterDescriptor("Text", FilterOperator.StartsWith, "T2"));
        }
        if (this.radListView1.Items[2].CheckState == ToggleState.On)
        {
            des.FilterDescriptors.Add(new FilterDescriptor("Text", FilterOperator.StartsWith, "T3"));
        }
         
        this.radListView2.FilterDescriptors.Clear();
        this.radListView2.FilterDescriptors.Add(des);
    }

    Do not hesitate to contact us, if you have any additional questions.

    Greetings,
    Ivan Todorov
    the Telerik team

    SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

  8. Jorge
    Jorge avatar
    1 posts
    Member since:
    Feb 2015

    Posted 10 Sep 2015 Link to this post

    Hello,

    And as it would be to implement a custom icons view?

    filtering a radlabelelement within a stack added to radlistview in iconsview mode.

  9. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    711 posts

    Posted 11 Sep 2015 Link to this post

    Hello Jorge,

    Thank you for writing.

    I am not sure that I completely understand your question. Could you please provide me with details about your scenario and the type of functionality you are after?

    Looking forward to hearing from you.

    Regards,
    Hristo Merdjanov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for WinForms is Visual Studio 2017 Ready