Filter Modes and Custom Filtering

  • 2 minutes to read


Filtering by display text and custom filtering are not supported in server mode.

Filter Modes

The grid allows its data to be filtered by column values (edit values) or display text. Use the ColumnBase.ColumnFilterMode property to specify the column’s filter mode.

Custom Filtering

Custom filtering is hiding particular rows that exist in a data source, or making them visible. Custom filtering takes priority over filter criteria applied using a column’s filter dropdown or using the Automatic Filter Row.

To manually filter data rows, handle the GridControl.CustomRowFilter event. This event is raised for each record in a data source. The currently processed record is identified by its index in a data source, returned by the event parameter’s ListSourceRowIndex property. To identify the row which corresponds to the processed record, use the GridControl.GetRowHandleByListIndex method.

To hide or show a row, specify the event parameter’s Visible property and set the Handled property to true. If the Handled parameter is set to false, the record’s visibility is determined by the filter currently applied to a View. So, the record will only be visible if it matches the View’s filter. Otherwise, it will be hidden.


The following example demonstrates how to apply a custom filter condition to the GridControl:

DevExpress WPF | Grid Control - Custom Filter Rules

View Example: How to Apply a Custom Filter Condition

        <RowDefinition Height="36" />
        <RowDefinition Height="*" />
    <StackPanel Grid.Row="0" Orientation="Horizontal">
        <CheckBox Name="chkHideEven"
                  Content="Hide Even Rows"
                  Unchecked="OnCheckedChanged" />
        <CheckBox Name="chkHideOdd"
                  Content="Hide Odd Rows"
                  Unchecked="OnCheckedChanged" />
    <dxg:GridControl Name="grid"
            <dxg:TableView Name="view"
                           NavigationStyle="None" />
void OnCustomRowFilter(object sender, RowFilterEventArgs e) {
    if(chkHideOdd.IsChecked.Value && e.ListSourceRowIndex % 2 == 1)
        e.Visible = false;
    if(chkHideEven.IsChecked.Value && e.ListSourceRowIndex % 2 == 0)
        e.Visible = false;
    e.Handled = !e.Visible ? true : false;

void OnCheckedChanged(object sender, RoutedEventArgs e) {