Show theme settings Shopping cart Download trialFree Trial
Change Theme Settings
Change Theme Settings
Show All Themes

Custom Filter Functions

Product Name 
Order Date 
Unit Price 
Queso CabralesSweden10/11/20215016.8020%
Nord-Ost MatjesheringSweden10/11/20213520.7020%
Escargots de BourgogneSweden10/11/20213010.6020%
Rogede sildUnited Kingdom12/19/2021157.6020%
Filo MixUnited Kingdom12/19/2021205.6020%
Mishi Kobe NikuGermany4/23/20211697.0015%
Camembert PierrotGermany4/23/20218434.0015%
Page 1 of 48 (472 items)Prev1234567464748Next
Show filter builder dialogIsSalesDiscount([Discount]) Clear

This demo shows how you can create and register custom filter operators for use with the DevExpress ASP.NET MVC Grid View (GridViewExtension).

Our Grid View extension ships with an integrated Filter Control. This filter control allows users to specify and combine predefined or custom filter conditions. The result is synchronized with the MVCxGridView.FilterExpression property that you can set in code. Users can specify an expression if they switch from Visual to Text tab in the Filter Control. Use the SettingsFilterControl.ViewMode property to specify tab availability.

This demo implements three custom operators:

  • IsSalesDiscount. Available for the Discount field. Filters out values less than 15% (0.15).
  • DoesNotBeginWith. Available for ProductName and Country fields. Filters out values that begin with the specified argument.
  • IsWeekend. Available for the OrderDate field. Filters out values that don’t fall on weekends.

Review operator implementation in “Model (CustomFunctions)”. Each custom operator is a class that implements the ICustomFunctionDisplayAttributes interface. The CriteriaOperator.RegisterCustomFunction method call registers the operator in the Grid View.

You need to explicitly enable custom operators for use in the Filter Control UI. Review the code-behind file to learn how to do that. The FilterControlOperationVisibility event sets the e.Visible argument to true for applicable operator/field pairs.

Local Copy of this Demo
To inspect the source code for this demo on your machine, you must first install our components via the DevExpress Component Installer.
You can open a local copy of this online demo directly from this webpage (if using v20.2.8, 21.1.4 or higher).
Open CS Solution
The source code files for this demo are installed (by default) in the following directory:
\Users\Public\Documents\DevExpress Demos XX.X\Components\ASP.NET\CS\MVCxGridViewDemos