Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to filter TreeViewAdv with RecordFilters

I am new to C# and SyncFusion and would really appreciate your help.

I need to have the correct records shown in TreeViewPresenter(TreeViewAdv) after filtering gridGroupingControl.

First I thought about to get the filters with:

detailGroupingControl.TableDescriptor.RecordFilters

and to set these filters in the TreeViewPresenter but it seems that it doesn't work like that. Are there any easy methods to filter the tree with the same filtering criterias as gridGroupingControl?

like image 929
ninjaxelite Avatar asked Aug 17 '15 10:08

ninjaxelite


1 Answers

If you want to add the RecordFilters from one TreeView node to another TreeView node, you have to add the objects of the grid in a list. Using this list, the filtering can be reflected to all the TreeView nodes. Please refer the below code and sample for reference,

//Used to save the objects of all grids
List<GridGroupingControl> grids = new List<GridGroupingControl>();

//add the grid to the list
grids.Add(GridGroupingControl);

void RecordFilters_Changed(object sender, Syncfusion.Collections.ListPropertyChangedEventArgs e)
{
    Syncfusion.Grouping.RecordFilterDescriptorCollection filters = sender as RecordFilterDescriptorCollection;
    foreach (GridGroupingControl grid in grids)
    {
        foreach(RecordFilterDescriptor filter in filters)
        {
            //To avoid the repeated objects from the list
            if (grid.TableDescriptor.RecordFilters.Contains(filter))
                continue;
            grid.TableDescriptor.RecordFilters.Add(filter);
        }
    }
}
like image 82
Venkatesh Ks Avatar answered Oct 13 '22 09:10

Venkatesh Ks