Thursday 31 March 2011

RadTreeView Composite Filtering

If you've seen the latest release of the RadTreeView for WinForms from Telerik, then you can't have failed to notice the new filtering possibility.

As per the RadTreeView Filtering Help Topic you simply set Filter property to be the text of the node that you wish to filter. E.g.

this.radTreeView1.Filter = "new";

But, what's not mentioned either in the help or in the demo, is that you can be more verbose with your filtering criteria. Because the RadTreeView now contains a similar engine to the other RadControls, such as the RadGridView, it's possible to add CompositeFilters to the RadTreeView too.

For exmaple, if you would like to filter to find nodes that are either called Node2, or Node 9 then you can define a composite filter as follows:

CompositeFilterDescriptor compositeFilter = new CompositeFilterDescriptor();
compositeFilter.FilterDescriptors.Add(new FilterDescriptor("Text", FilterOperator.IsEqualTo, "Node2"));
compositeFilter.FilterDescriptors.Add(new FilterDescriptor("Text", FilterOperator.IsEqualTo, "Node9"));
compositeFilter.LogicalOperator = FilterLogicalOperator.Or;
this.radTreeView1.FilterDescriptors.Add(compositeFilter);





1 comment: