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).
\Users\Public\Documents\DevExpress Demos XX.X\Components\ASP.NET\CS\MVCxGridViewDemos |