Automatic Filter Row
- 3 minutes to read
The automatic filter row allows end-users to filter data. An end-user should type the text within the row to apply a filter condition.
The automatic filter row is hidden. Set the TableView.ShowAutoFilterRow property to true to activate the automatic filter row.
When an end-user modifies the automatic filter row cell’s text, the GridControl updates the column’s filter condition immediately. Set the ColumnBase.ImmediateUpdateAutoFilter property to false to disable the column’s automatic updates. In this case, to update the cell an end-user should press the Enter key or focus another cell.
Clear the automatic filter row‘s text to remove filters.
Note
If the ColumnBase.ShowCriteriaInAutoFilterRow property is set to true, the GridControl does not use the ColumnBase.AutoFilterCondition property. In this case, use the ColumnBase.AutoFilterCriteria property to apply the required condition.
Automatic Filter Row Settings
Availability
Use the ColumnBase.AllowAutoFilter property to specify whether you can filter this column’s values with the automatic filter row. The corresponding cell within the automatic filter row is disabled if this property is set to false.
Comparison Operator Type
The ColumnBase.AutoFilterCondition property allows you to specify the column’s comparison operator type (Contains, Equals or Like).
Identifier
The automatic filter row’s handle identifies this row. Use the static GridControl.AutoFilterRowHandle field to get the handle.
Row Data
Use the ColumnBase.AutoFilterValue property to get or set the automatic filter row‘s column value.
Filter Criteria Selector
Set the ColumnBase.ShowCriteriaInAutoFilterRow property to true to enable a filter criteria selector. This selector allows end-users to apply the required criteria type to the required column.
Set the TableView.ShowCriteriaInAutoFilterRow (TreeListView.ShowCriteriaInAutoFilterRow) property to true to enable a filter criteria selector for all columns.
Filter Row Delay
You can specify the filter delay time in milliseconds with the DataViewBase.FilterRowDelay property. The following code sample creates a GridControl with 1-second column filtering delay:
<dxg:GridControl ItemsSource="{Binding Customers}"> <dxg:GridControl.View> <dxg:TableView ShowAutoFilterRow="True" FilterRowDelay="1000"/> </dxg:GridControl.View> </dxg:GridControl>
Filter Condition Update Mode
The GridControl updates the filter condition when an end-user modifies the automatic filter row‘s text. You can set the ColumnBase.ImmediateUpdateAutoFilter property to false to disable the column’s automatic updates. In this mode, the filter criteria is applied when an end-user presses the Enter key or focuses another cell.
<dxg:GridControl ItemsSource="{Binding Customers}"> <dxg:GridControl.View> <dxg:TableView ShowAutoFilterRow="True"/> </dxg:GridControl.View> <dxg:GridColumn FieldName="Name" ImmediateUpdateAutoFilter="False"/> </dxg:GridControl>
Filter Criteria
A cell’s filter criterion depends on the ColumnBase.AutoFilterCondition and ColumnBase.AutoFilterCriteria properties:
- When the ColumnBase.AutoFilterCriteria property is not null, the automatic filter row uses the criterion specified in this property.
The automatic filter row uses the ColumnBase.AutoFilterCriteria property and ignores the ColumnBase.AutoFilterCondition property if the ColumnBase.ShowCriteriaInAutoFilterRow property is set to true.
When the ColumnBase.AutoFilterCriteria is null, the automatic filter row chooses a filter criterion depending on the column type and the ColumnBase.ColumnFilterMode.
- The automatic filter row uses the ColumnBase.AutoFilterCondition when the ColumnBase.AutoFilterCriteria property is null.
Note
The automatic filter row‘s cell is disabled when the corresponding filter criterion is removed. Refer to the Allowed Filters topic for information on how to specify the allowed filters.
The automatic filter row chooses the default filter criterion in the following order:
- If a cell’s ColumnBase.EditSettings property is CheckEditSettings, the filter criterion is Equals. The ColumnBase.ColumnFilterMode, ColumnBase.AutoFilterCondition, and ColumnBase.AutoFilterCriteria properties are ignored.
- If a cell’s ColumnBase.ColumnFilterMode property is DisplayText or ColumnBase.FieldType property is String, the filter criterion is StartsWith.
- If a cell’s ColumnBase.FieldType property is byte[], the filter criterion is IsNotNull.
- If a cell’s ColumnBase.ShowCriteriaInAutoFilterRow property is true, the filter criterion is Equals.
- If a cell’s ColumnBase.ShowCriteriaInAutoFilterRow property is false, the filter criterion is StartsWith.
Note
When the ColumnBase.ShowCriteriaInAutoFilterRow property is true, the filter criteria selector contains only allowed filter criteria.