Add Filter to RadListFilterPopup

6 posts, 0 answers
  1. Ingo
    Ingo avatar
    16 posts
    Member since:
    Apr 2016

    Posted 13 Apr Link to this post

    Hello,

    I use a hierarchical grid in my application.

    I like to use an Excel like filter for the child rows, but the grid is filled with data by data binding or load on demand so the automatic filter selections are not provided by the grid. (See attached file). Now I like to manually add some filter checkboxes under the "All" checkbox, but I can't figure out how to achieve that.

    I know this has to be done in the FilterPopupRequired event......

     

    Thanks for Your help!

    Regards

    Ingo

  2. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    711 posts

    Posted 13 Apr Link to this post

    Hi Ingo,

    Thank you for writing.

    The RadListFilterPopup internally contains a RadTreeView instance which can be accessed and modified. In order to achieve your task, indeed, you would need to handle the FilterPopupRequired event. Please check my code snippet below:
    private void radGridView1_FilterPopupRequired(object sender, FilterPopupRequiredEventArgs e)
    {
        if (e.Column.Name == "Name")
        {
            RadListFilterPopup popup = e.FilterPopup as RadListFilterPopup;
            popup.MenuTreeElement.TreeView.Nodes.Add("MyNode");
        }
    }

    I hope this helps. Please let me know if you need further assistance.

    Regards,
    Hristo Merdjanov
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Ingo
    Ingo avatar
    16 posts
    Member since:
    Apr 2016

    Posted 13 Apr Link to this post

    Hello,

    thank You for Your quick response.

    Adding an entry to the treeview works!

    The question is now how to achieve the filtering of the elements in the column: Deselecting this custom node (or several nodes) hides the rows that match the node(s) in this column and reselecting (remember the state of the check box?) shows them again.

     

    Thank You!

     

    Regards

    Ingo

  5. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    711 posts

    Posted 14 Apr Link to this post

    Hello Ingo,

    Thank you for writing back.

    If I understand correctly you would like to use this custom node to filter the child templates of your grid which is set in a hierarchy.

    Basically, you would need to handle the NodeCheckedChanged event of the tree and based on your logic add or remove a filter from your child template. Detailed information how filters can be added programmatically is available here: Setting Filters Programmatically (simple descriptors).

    I am also sending you a sample project handling a basic scenario which I believe should get you going.

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo Merdjanov
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  6. Ingo
    Ingo avatar
    16 posts
    Member since:
    Apr 2016

    Posted 20 Apr Link to this post

    Hello,

    thank You very much for Your answer and Your example. It works very well.

    I just have a question about Your example:

    In Your example You use AutoGenerateHierarchy = true and You bind the data of the grid to a data source. In Your case the excel like filtering works automatically.

    In my case I use a List<> of objects and each one has a sub object List<> (my data in memory). The hierarchy is generated perfectly but the Excel like filters are not generated.

    I thought that in general that the excel like filtering does not work for child elements when the data is filled by a data source and the hierarchy is generated automatically because of the lazy load of the data (from database or from object list). But Your example shows that it can work!

    The question is what are the prerequisites needed or what can I do to make the automatic filtering work (e.g. use another object in memory)?

     

    Thank You very much!

    Regards,

    Ingo

  7. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    711 posts

    Posted 20 Apr Link to this post

    Hello Ingo,

    Thank you for writing.

    I am glad that the example works well on your end. RadGridView utilizes the standard WinForms data binding mechanism. When the grid has been set up in a hierarchy and unless the Load on Demand functionality is being used all of its templates are filled with data right from the beginning.

    In this scenario, you would be able to use the suggested approach and add filters in the filter popup of the master template filtering any of the child templates.

    I hope this information was useful. Please let me know if you need further assistance.

    Regards,
    Hristo Merdjanov
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Back to Top
UI for WinForms is Visual Studio 2017 Ready