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

CompositeFilterDescriptor

The CompositeFilterDescriptor represents a special type of descriptor that stores an arbitrary number of other descriptor instances. The logical AND or OR operator is applied upon all composed filters to determine whether an object passes the filter.

Adding a CompositeFilterDescriptor

Example 1 show how to create two NumericalFilterDescriptors and apply them both using a CompositeFilterDescriptor. In this case the condition we are filtering by is that the value of the CityPopulation property should be greater than 20 000 and less than 1 000 000. Both conditions should pass as the Operator we are using is And.

Example 1: Adding the RadDataGrid in xaml

<Grid xmlns:grid="using:Telerik.UI.Xaml.Controls.Grid" 
      xmlns:dataCore="using:Telerik.Data.Core"> 
    <grid:RadDataGrid x:Name="grid" VerticalAlignment="Center"> 
        <grid:RadDataGrid.FilterDescriptors> 
            <dataCore:CompositeFilterDescriptor Operator="And"> 
                <dataCore:CompositeFilterDescriptor.Descriptors> 
                    <dataCore:NumericalFilterDescriptor PropertyName="CityPopulation" 
                                       Operator="IsGreaterThan" 
                                       Value="20000"/> 
                    <dataCore:NumericalFilterDescriptor PropertyName="CityPopulation" 
                                       Operator="IsLessThan" 
                                       Value="1000000"/> 
                </dataCore:CompositeFilterDescriptor.Descriptors> 
            </dataCore:CompositeFilterDescriptor> 
        </grid:RadDataGrid.FilterDescriptors> 
    </grid:RadDataGrid> 
</Grid> 

Example 2: Populating the RadDataGrid

public sealed partial class MainPage : Page 
{ 
    public MainPage() 
    { 
        this.InitializeComponent(); 
 
        List<CustomData> data = new List<CustomData> 
        { 
            new CustomData { Country = "Brazil", City = "Caxias do Sul", CityPopulation = 450000 }, 
            new CustomData { Country = "Brazil", City = "Fortaleza", CityPopulation = 2500000 }, 
            new CustomData { Country = "Spain", City = "Malaga", CityPopulation = 569000 }, 
            new CustomData { Country = "Bulgaria", City = "Koynare", CityPopulation = 5000 }, 
            new CustomData { Country = "Spain", City = "Valencia", CityPopulation = 810000 }, 
            new CustomData { Country = "Ghana", City = "Kade", CityPopulation = 16000 }, 
            new CustomData { Country = "Brazil", City = "Porto Alegre", CityPopulation = 1510000 }, 
            new CustomData { Country = "Bulgaria", City = "Byala Slatina", CityPopulation = 11000 }, 
            new CustomData { Country = "Brazil", City = "Joinville", CityPopulation = 515000 }, 
        }; 
        this.grid.ItemsSource = data; 
    } 
} 
 
public class CustomData 
{ 
    public string Country { get; set; } 
 
    public string City { get; set; } 
 
    public double CityPopulation { get; set; } 
} 

Figure 1: RadDataGrid before and after filtering

CompositeFilterDescriptor example

See Also

In this article
Not finding the help you need?