RadDataGrid provides built-in filtering functionality, that allows the user to easily filter data by one or more columns. Everything that can be achieved by the end user through the UI can also be done in code by using the API exposed by the control.
The built-in Filtering UI allows the user to easily filter data by column values. The filtering functionality will be enabled out-of-the-box for most .NET primitive types such as strings, numeric types, DateTimes and so on.
As can be seen in the image above, the default filtering UI consists of two parts - a distinct filters list and two field filters.
If you want to hide the top part of this UI (the distinct values) for a particular column, you can set the ShowDistinctValuesFilter property of the respective column to False.
Example 1: Hide the distinct values list
<grid:DataGridTextColumn PropertyName="City" ShowDistinctValuesFilter="False" />
Example 2: Disable the filtering functionality
<grid:RadDataGrid UserFilterMode="Disabled" />
Example 3: Disable the filtering functionality of a column
<grid:DataGridTextColumn PropertyName="City" CanUserFilter="False" />
There are two filter modes that depend on the value of the ColumnDataOperationsMode property of the RadDataGrid.
Inline Filter UI: The ColumnDataOperationsMode is set to Inline. The Filter UI is integrated in the column header and is represented by a filtering funnel which can be clicked to open the filtering popup. This is the default behavior.
Figure 1: Inline ColumnDataOperationsMode
Flyout Filter UI: The ColumnDataOperationsMode is set to Flyout. The Filter UI is displayed with slide animation from the top of the grid. To open it, click the column's header cell.
Figure 2: Column Data Operations Menu
If you then click on the Filter button, you will be presented with the filtering flyout.
Figure 3: Flyout ColumnDataOperationsMode
Example 4: Setting the ColumnDataOperationsMode
<grid:RadDataGrid ColumnDataOperationsMode="Flyout" />
RadDataGrid also allows for programmatic filtering through adding FilterDescriptors to its FilterDescriptors collection.
- Delegate Filter Descriptor