Skip to main content
Tab

ASPxGridViewAutoFilterEventArgs Class

Provides data for the ASPxGridView.ProcessColumnAutoFilter event.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v24.1.dll

NuGet Package: DevExpress.Web

Declaration

public class ASPxGridViewAutoFilterEventArgs :
    GridAutoFilterEventArgs

Example

In this example, the ASPxGridView.ProcessColumnAutoFilter event is handled to allow end-users to filter employees by the year of birth.

Since the BirthDate column displays DateTime values, the DateTime editor is used to specify the filter criteria. To allow end-users to only enter the year, the default editor is replaced with the text editor within the ASPxGridView.AutoFilterCellEditorCreate event handler.

The image below shows the result:

ProcessColumnAutoFilter

using DevExpress.Web.ASPxEditors;
using DevExpress.Data.Filtering;

protected void ASPxGridView1_ProcessColumnAutoFilter(object sender,
    DevExpress.Web.ASPxGridViewAutoFilterEventArgs e) {
    if(e.Column != ASPxGridView1.Columns["BirthDate"]) return;

    if (e.Kind == DevExpress.Web.GridViewAutoFilterEventKind.CreateCriteria) {
        // Creates a new filter criterion and applies it.
        e.Criteria = null;
        int year;
        if (!int.TryParse(e.Value, out year)) return;
        e.Criteria = (new OperandProperty("BirthDate") >= new DateTime(year, 1, 1)) &
                          (new OperandProperty("BirthDate") < new DateTime(year + 1, 1, 1));
    }
    else {
        DateTime res;
        if (!DateTime.TryParse(e.Value, out res)) {
            e.Value = string.Empty;
        }
        else {
            // Specifies the text displayed within the auto-filter row cell.
            e.Value = res.Year.ToString();
        }
    }
}
protected void ASPxGridView1_AutoFilterCellEditorCreate(object sender,
     DevExpress.Web.ASPxGridViewEditorCreateEventArgs e) {

    // Replaces the default editor used to edit DateTime values with the text editor.
if (e.Column == ASPxGridView1.Columns["BirthDate"]) e.EditorProperties = new TextBoxProperties();
}
See Also