[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Expand]Data Grid
  [Collapse]Vertical Grid
   [Expand]Binding to Data
   [Expand]Data Layout: Records, Rows and Cells
   [Expand]Layouts
   [Expand]Data Editing and Validation
    Filtering
    Formatting Values
   [Expand]Drag and Drop
   [Expand]Appearance and Custom Painting
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Expand]End-User Capabilities
    Hit Information
    Batch Modifications
   [Expand]Member Tables
   [Expand]Examples
  [Expand]Property Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [Expand]TreeMap Control
  [Expand]Sunburst Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[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)

Filtering

You can filter grid data using pop-up menus, filter panel, filter editor, or in code.

Expanded Pop-up Filter Menus

Demo

Run the Vertical Grid module in the XtraVerticalGrid MainDemo to see the filtering functionality in action.

An end user can click the filter button in a row's header to invoke a pop-up filter menu. This menu contains data values and filters based on the data type.

Use the following properties to access filter options:

For example, use the following properties to prevent end users from filtering data (you can still filter data in code):

  • for the grid — the VGridControl.OptionsFilter.AllowFilter property (see VGridOptionsFilter.AllowFilter);
  • for a particular row — the BaseRow.Properties.OptionsFilter.AllowFilter property (see VGridOptionsRowFilter.AllowFilter).

Expanded Filter Panel

Once a filter is applied to data, the filter panel is displayed.

The filter panel is only displayed when a filter is applied, and automatically hides otherwise. The VGridControlBase.OptionsView.ShowFilterPanelMode property (see VGridOptionsView.ShowFilterPanelMode) specifies the filter panel’s visibility.

The filter panel displays the applied filter. You can handle the VGridControl.CustomFilterDisplayText event to customize the text.

The drop-down button in the filter panel displays a list of recently applied filters. You can disable this functionality or limit the number of items in the list (the default is 7) using the VGridOptionsFilter.AllowMRUFilterList and VGridOptionsFilter.MRUFilterListPopupCount options.

Expanded Filter Editor

In the filter panel, end users can click the Edit Filter button to invoke the filter editor. Set the VGridOptionsFilter.AllowFilterEditor property to false to disable the editor.

The editor provides the visual and text views. The VGridOptionsFilter.DefaultFilterEditorView option allows you to specify the view.

Note

Starting with v18.1, the filter editor allows a user to type filter expressions in the Text tab. This tab supports syntax highlighting and auto-complete. To revert data-aware controls to the legacy filter editor, disable the static WindowsFormsSettings.UseAdvancedFilterEditorControl property.

Expanded How to: Filter Data by Multiple Columns from a Single Menu

Demo

See the "Name" row in the Vertical Grid module in the XtraVerticalGrid MainDemo to see grouped filters in action.

A row's filter menu shows only values available in that row. To filter data by multiple row, invoke each row's menu.

It is also possible to group filter values in the current row's filter menu by values in another row. This allows you to filter data for multiple rows from a single menu.

To enable this feature, use the row's EditorRow.Properties.OptionsFilter.PopupExcelFilterGrouping property (see VGridOptionsRowFilter.PopupExcelFilterGrouping). This property specifies data fields (rows) by which to group filter values in this row's filter menu. Data fields (rows) should be specified by their names as strings separated by the comma, semicolon, space or tab character.

The code below shows how to display available categories below each trademark as illustrated in the figure above.

You can specify two or more data fields (rows) to group filter values by multiple rows. The field name order determines the group hierarchy. To show available trademarks below each category in the Trademark row's filter menu, you can change the group hierarchy using the following code.

As a result, values from the Category row are shown at the root level.

For a Code First data source, you can use the same syntax in the attribute parameter to annotate data fields with the FilterGroup attribute. See Filtering Attributes to learn more.

Expanded How to Filter Data in Code

On the grid level, you can specify a filter using the following API:

  • the VGridControl.ActiveFilterString property — gets and sets the active filter as a string expression. This property returns the same value as the ActiveFilter.Expression property;

    See Criteria Language Syntax to learn how to create filter expressions.
  • the VGridControl.ActiveFilterCriteria property — gets or sets the active filter as a CriteriaOperator object. This property returns the same value as the ActiveFilter.Criteria property;

    See Creating Criteria to learn how to create filter criteria.
  • the VGridControl.ActiveFilterEnabled property — allows you to temporary disable the active filter;
  • the VGridControl.CustomRecordFilter event — allows you to customize the filter applied by an end user;
  • the VGridControl.ActiveFilter property — provides access to the filter applied to the grid and the collection of filters applied to particular rows:
    • the indexer — allows you to obtain the filter applied to a particular row. You can also iterate through the collection using the zero-based index;
      The returned filter exposes:
      • Properties — gets the properties (see BaseRow.Properties) of the row to which the filter is applied;
      • Filter — provides access to information about the filter (see RowProperties.FilterInfo). You can use this property to specify a filter at the row level (see below).
    • the NonRowFilterCriteria
    • property — gets or sets a filter which is applied, but not associated with a particular row;
    • the Changed
    • event — fires when a row filter changes.

On the row level, you can specify a filter using the following property:

  • RowProperties.FilterInfo — gets or sets the filter applied to the row.

Expanded See Also

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