New to Telerik UI for Silverlight? Download free 30-day trial

Programmatic Filtering

Programmatic filtering is performed by adding a FilterDescriptor object to the FilterDescriptors collection of the control.

For example:

FilterDescriptor fd = new FilterDescriptor("PostalCode", FilterOperator.IsEqualTo, 1010); 
Dim fd As New FilterDescriptor("PostalCode", FilterOperator.IsEqualTo, 1010) 

On running the application, the following grid will be displayed:

You can build infinitely nested hierarchies of filters by using the CompositeFilterDescriptor class. The following code will return all people that were born in the 1980’s, but you could easily replace f1 or f2 with another composite filter to achieve logical nesting:

CompositeFilterDescriptor cfd = new CompositeFilterDescriptor(); 
cfd.LogicalOperator = FilterCompositionLogicalOperator.Or; 
FilterDescriptor f1 = new FilterDescriptor("City", FilterOperator.IsEqualTo, "Berlin"); 
FilterDescriptor f2 = new FilterDescriptor("City", FilterOperator.IsEqualTo, "Madrid"); 
Dim cfd As New CompositeFilterDescriptor() 
cfd.LogicalOperator = FilterCompositionLogicalOperator.[Or] 
Dim f1 As New FilterDescriptor("City", FilterOperator.IsEqualTo, "Berlin") 
Dim f2 As New FilterDescriptor("City", FilterOperator.IsEqualTo, "Madrid") 

Once the application is loaded, you will see the prefiltered grid:

In this article
Not finding the help you need? Improve this article