DataControlBase.FilterString Property
Gets or sets the grid’s filter expression. This is a dependency property.
Namespace: DevExpress.Xpf.Grid
Assembly: DevExpress.Xpf.Grid.v24.2.Core.dll
NuGet Package: DevExpress.Wpf.Grid.Core
Declaration
Property Value
Type | Description |
---|---|
String | A String value that specifies the grid’s filter expression. |
Remarks
Tip
Topic: Filtering in Code
Use the FilterString property to create a filter expression that consists of multiple conditions applied to multiple columns, and apply it to the grid. When you set the FilterString property to a new value, GridControl clears any filters that have been previously applied.
<dxg:GridControl FilterString="([OrderDate] < #1/1/1995# AND [UnitPrice] < 10) OR ([OrderDate] >= #1/1/1996# AND [UnitPrice] >= 100)" />
grid.FilterString = "([OrderDate] < #1/1/1995# AND [UnitPrice] < 10)" +
" OR ([OrderDate] >= #1/1/1996# AND [UnitPrice] >= 100)";
The DataControlBase.GetColumnFilterString method allows you to obtain the filter expression applied to an individual column.
Note
The filter string is processed by the CriteriaOperator.Parse method internally. Refer to the Limitations of CriteriaOperator.Parse topic to learn more.
FilterCriteria Property
Use the DataControlBase.FilterCriteria property to create a filter expression that consists of multiple conditions applied to multiple columns, and apply it to the grid. When you set the DataControlBase.FilterCriteria property to a new value, GridControl clears any filters that have been previously applied.
You should create a CriteriaOperator object or its descendant representing the filter expression:
grid.FilterCriteria = (
new BinaryOperator("OrderDate", new DateTime(1995, 1, 1), BinaryOperatorType.Less) &
new BinaryOperator("UnitPrice", 10, BinaryOperatorType.Less)) |
( new BinaryOperator("OrderDate", new DateTime(1996, 1, 1), BinaryOperatorType.GreaterOrEqual) &
new BinaryOperator("UnitPrice", 100, BinaryOperatorType.GreaterOrEqual));
You can apply filter criteria by parsing a filter string with the static CriteriaOperator.Parse method:
grid.FilterCriteria =
CriteriaOperator.Parse("([OrderDate] < #1/1/1995# AND [UnitPrice] < 10)" +
" OR ([OrderDate] >= #1/1/1996# AND [UnitPrice] >= 100)");
Note
Use a column’s FieldName value to specify a filter expression with the DataControlBase.FilterCriteria / FilterString property. Refer to the How the GridControl Identifies Columns topic for more information.
Related API
Use the DataControlBase.GetColumnFilterCriteria method to obtain a filter applied to a column.
Use the DataControlBase.MergeColumnFilters method to apply a filter to a column(s) preserving the grid’s filter (if applied).
Use the DataControlBase.ClearColumnFilter method to clear the required column’s filter.
End users can modify filters that you set using the FilterString and DataControlBase.FilterCriteria properties. Use the DataControlBase.FixedFilter property to specify a filter criteria that cannot be modified.
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the FilterString property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.