DataControlBase.FilterCriteria Property

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

Namespace: DevExpress.Xpf.Grid

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

Declaration

[Browsable(false)]
public CriteriaOperator FilterCriteria { get; set; }
<Browsable(False)>
Public Property FilterCriteria As CriteriaOperator

Property Value

Type Description
CriteriaOperator

A CriteriaOperator object which represents filter criteria.

Remarks

Use the 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 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)");

FilterString Property

The DataControlBase.FilterString property allows you to specify a filter string:

<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)";
NOTE

Use a column's FieldName value to specify a filter expression with the FilterCriteria / DataControlBase.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 FilterCriteria and DataControlBase.FilterString properties. Use the DataControlBase.FixedFilter property to specify a filter criteria that cannot be modified.

Implements

DevExpress.Xpf.Core.IDXFilterable.FilterCriteria
See Also