This is a migrated thread and some comments may be shown as answers.

Add Filter to RadListFilterPopup

5 Answers 139 Views
GridView
This is a migrated thread and some comments may be shown as answers.
LIMA Factory
Top achievements
Rank 1
LIMA Factory asked on 13 Apr 2016, 06:29 AM

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

5 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 13 Apr 2016, 08:14 AM
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.
0
LIMA Factory
Top achievements
Rank 1
answered on 13 Apr 2016, 09:10 AM

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

0
Hristo
Telerik team
answered on 14 Apr 2016, 02:43 PM
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.
0
LIMA Factory
Top achievements
Rank 1
answered on 20 Apr 2016, 06:40 AM

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

0
Hristo
Telerik team
answered on 20 Apr 2016, 04:43 PM
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.
Tags
GridView
Asked by
LIMA Factory
Top achievements
Rank 1
Answers by
Hristo
Telerik team
LIMA Factory
Top achievements
Rank 1
Share this question
or