[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
  Prerequisites
 [Expand]What's Installed
 [Expand].NET Core 3 Support
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
   Reporting
  [Collapse]Data Grid
   [Expand]Getting Started
   [Expand]Implementation Details
   [Expand]Views
   [Expand]Grid View Data Layout
   [Expand]Binding to Data
   [Expand]Master-Detail Data Representation
   [Expand]Data Editing and Validation
   [Expand]Grouping
   [Collapse]Filtering and Searching
    [Expand]Drop-down Filter
     Automatic Filter Row
     Filter Editor
     Filter Elements
    [Expand]Filtering in Code
     Predefined Filters
     Data Analysis Filters
     Conditional Formatting Filters
    [Expand]Search
   [Expand]Sorting
   [Expand]Data Summaries
   [Expand]Paging and Scrolling
   [Expand]Focus, Navigation, Selection
   [Expand]Drag-and-Drop
   [Expand]Conditional Formatting
   [Expand]Appearance Customization
   [Expand]MVVM Enhancements
   [Expand]Printing and Exporting
   [Expand]Miscellaneous
   [Expand]Performance Improvement
   [Expand]Design-Time Features
   [Expand]Visual Elements
   [Expand]End-User Capabilities
   [Expand]Examples
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Printing-Exporting
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Gantt Control
  [Expand]Diagram Control
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
  [Expand]Scheduler (legacy)
 [Expand]Scaffolding Wizard
 [Expand]Localization
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Filter Editor

The Filter Editor allows users to build filter criteria. They can add filter conditions and use logical operators to group filters.

Note

v19.1 and later use the new Filter Editor.

To use the previous Filter Editor:

The Server Mode and Virtual Sources use the previous Filter Editor.

Expanded Invoke the Filter Editor

Users can invoke the Filter Editor in the following ways:

  • Right-click the column's header and select Filter Editor...:

  • Click the Edit Filter button ( ) in the Filter Panel:

Tip

Set the DataViewBase.AllowFilterEditor property to false to prohibit users from invoking the Filter Editor.

To invoke the Filter Editor in code, call the DataViewBase.ShowFilterEditor method or the DataViewCommandsBase.ShowFilterEditor command:

Expanded Filter Editor UI

The Filter Editor displays filter criteria as a tree structure where nodes are filter conditions. The Filter Editor groups filter conditions by logical operators if the filter criteria consist of several filter conditions.

Expanded Conditional Formatting Filters

You can filter data by applying Conditional Formatting rules. The Filter Editor displays available rules and indicates the number of records that meet rule conditions:

Tip

Demo: Conditional Formatting

Requires a WPF Subscription. Download

Expanded Customize the Filter Editor

Use the DataViewBase.FilterEditorTemplate property to specify a custom data template. In the template, define the FilterEditorControl and handle its events.

Customize the Field List

Tip

Demo: Filter Editor - Customize the Field List

Requires installation of WPF Subscription. Download

The Filter Editor shows a list of the GridControl's fields. If the GridControl has Bands, the Filter Editor shows fields in a hierarchical structure:

Tip

The FilterEditorControl.PropertySelectorMode property specifies whether to show fields in List or Tree mode.

Use the FilterEditorControl.QueryFields event to customize the field list. The following code sample shows how to add the ShipCountry, ShipCity, ShipAddress fields to the Ship category:

Customize the Operator List

Standard Operators

Tip

Demo: Filter Editor - Customize the Operator List

Requires installation of WPF Subscription. Download

The Filter Editor shows a list of operators the selected field accepts. Use the FilterEditorControl.QueryOperators event to customize the operator list.

The code sample below removes all operators except Equal and Not Equal:

Custom Operators

Tip

Demo: Filter Editor - Customize the Operator List

Requires installation of WPF Subscription. Download

You can use the FilterEditorControl.QueryOperators event to add custom operators. The code sample below adds the Last Years operator:

  1. Create a custom function. Do one of the following:

    • Use the CustomFunctionFactory.Create method.

      The CustomFunctionFactory is an extension of the DevExpress.Xpf.Grid.v19.2.Extensions.dll library. Refer to c:\Program Files (x86)\DevExpress 19.2\Components\Sources\DevExpress.Xpf.Grid\DevExpress.Xpf.Grid.Extensions\ for information on how extension methods work.

      The CustomFunctionFactory.Create method allows you to create a custom function with a maximum of 4 operands.

    • Implement the ICustomFunctionOperator interface. Refer to the Implementing Custom Functions topic for more information.

  2. Call the CriteriaOperator.RegisterCustomFunction method to register the custom function.

  3. Create the FilterEditorOperatorItem and add it to the FilterEditorQueryOperatorsEventArgs.Operators collection. Specify the operator item's edit settings (see BaseEditSettings) to define its operands:

Predefined Filters

You can specify Predefined Filters with the ColumnBase.PredefinedFilters property. The Filter Editor displays these filters in the Predefined filters submenu:

Tip

Topic: Predefined Filters

Customize Operand Template

Tip

Demo: Filter Editor - Customize Operands

Requires installation of WPF Subscription. Download

The Filter Editor automatically creates operand editors based on the field and operator type. You can customize operand editors.

The following code sample specifies the TrackBarEdit as an operand for the Between and NotBetween operators:

  1. Create a template for the operands. The following models depend on the operator type. Use their properties to bind to operand values in the template:

  2. Handle the FilterEditorControl.QueryOperators event, get the operator, and assign the created template to the OperatorItemBase.OperandTemplate property.

Prohibit Operations

Prohibit Group Types

Tip

Demo: Filter Editor - Prohibit Group Types

Requires installation of WPF Subscription. Download

Use the FilterEditorControl.QueryGroupTypes event to prohibit group types. The following code sample prohibits users from specifying the Or and NotOr logical operators:

Prohibit Group Operations

Tip

Demo: Filter Editor - Prohibit Group Operations

Requires installation of WPF Subscription. Download

Use the FilterEditorControl.QueryGroupOperations event to prohibit group operations. The following code sample prohibits users from adding custom Expressions:

Prohibit Removing Conditions

Tip

Demo: Filter Editor - Prohibit Condition Operations

Requires installation of WPF Subscription. Download

Use the FilterEditorControl.QueryConditionOperations event to prohibit users from removing conditions:

Expanded Standalone Filter Editor

Tip

Demo: Filter Editor - Standalone Filter Editor

Requires installation of WPF Subscription. Download

You can use a standalone FilterEditorControl to edit filters outside of the GridControl.

Specify the FilterEditorControl.Context property to associate the FilterEditorControl with the GridControl's filtering context:

The filter criteria specified in the FilterEditorControl are not automatically applied to the GridControl. To apply the current filter criteria, call the FilterEditorControl.ApplyFilter method or the FilterEditorCommands.ApplyFilter command.

Tip

Is this topic helpful?​​​​​​​