DataControlBase.FilterString Property

Gets or sets the grid's filter expression. This is a dependency property.

Namespace: DevExpress.Xpf.Grid

Assembly: DevExpress.Xpf.Grid.v20.1.Core.dll

Declaration

public string FilterString { get; set; }
Public Property FilterString As String

Property Value

Type Description
String

A String value that specifies the grid's filter expression.

Remarks

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.

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.

See Also