Filter Control

  • 2 min to read

The FilterControlExtension allows end users to build complex filter criteria with an unlimited number of filter conditions, combined by logical operators, and apply them to extensions or data models.

ASPxFilterControl_Overview

Features

Implementation

Use the FilterControl(MVCxFilterControlSettings) helper method to add the Filter Control (FilterControlExtension) extension to a view. The FilterControl(MVCxFilterControlSettings) method's parameter provides access to the filter control's settings (MVCxFilterControlSettings).

Declaration

The following code adds the filter control to a view.

View code (ASPX):

@{
    Html.DevExpress().GridView<Product>(settings => {
        settings.Name = "grid";
        settings.CallbackRouteValues = new { Controller = "Editors", Action = "FilterControl_GridPartial" };
        settings.Width = Unit.Percentage(100);

        settings.Columns.Add(c => c.ProductName);
        settings.Columns.Add(c => {
            c.FieldName = "CategoryID";
            c.Caption = "CategoryName";
        });

        settings.Columns.Add(c => c.Supplier.CompanyName);
        ...
    }).Bind(Model).Render();
}

View code (Razor):

@{
    Html.DevExpress().GridView<Product>(settings => {
        settings.Name = "grid";
        settings.CallbackRouteValues = new { Controller = "Editors", Action = "FilterControl_GridPartial" };
        settings.Width = Unit.Percentage(100);

        settings.Columns.Add(c => c.ProductName);
        settings.Columns.Add(c => {
            c.FieldName = "CategoryID";
            c.Caption = "CategoryName";
        });

        settings.Columns.Add(c => c.Supplier.CompanyName);
        ...
    }).Bind(Model).GetHtml();
}
Note

The Partial View should contain only the extension's code.

Online Demo

Filter Control Extension - Features