Skip to main content

Filter Panel

  • 6 minutes to read

The Filter Panel is displayed at the bottom of the PivotGridControl. The panel includes an existing filter expression (active or inactive) with a set of buttons to enable/disable, edit, or clear the filter.

Run Demo: Excel Style Filtering

Pivot Grid - Filter Panel

API Description
PivotGridControl.ShowFilterPanelMode Specifies whether to display the filter panel within the PivotGridControl.
PivotGridControl.ShowFilterPanel Returns whether the filter panel is displayed within the PivotGridControl.

Note

The Filter Panel does not display summary filters.

Enable/Disable Filter

Use the check box to enable/disable the current filter at runtime.

Pivot Grid - Enable Filter

API Description
PivotGridControl.IsFilterEnabled Specifies whether to enable/disable the current filter.

Filter Expression

If you apply filter conditions to individual columns, the PivotGridControl uses logical AND to combine these conditions into a single filter expression.

Pivot Grid - Filter Panel Expression

The Filter Panel highlights individual field names, field values, and date-time functions to increase the filter expression’s readability.

API Description
PivotGridControl.FilterString Gets or sets the filter expression applied to PivotGridControl data.
PivotGridControl.FilterCriteria Gets or sets the filter criteria applied to PivotGridControl data.

Expand/Collapse Panel

Click the Expand Panel button to display the entire filter expression if it does not fit the Filter Panel.

Pivot Grid - Remove Condition

Most Recently Used Filters

Click the button displayed in the image below to access the most recently applied filter expressions.

Pivot Grid - MRU Filter List

API Description
PivotGridControl.AllowMRUFilterList Specifies whether to display the drop-down MRU filter list and the Most Recently Used button.
PivotGridControl.MRUFilterListCount Specifies the maximum number of the most recently used filters the PivotGridControl stores.
PivotGridControl.MRUFilterList Returns a collection of the most recently used filters.
PivotGridControl.AddMRUFilter Adds the specified filter to the collection of the most recently used filters.
PivotGridControl.RemoveMRUFilter Removes the specified filter from the collection of the most recently used filters.
PivotGridControl.ClearMRUFilter Clears the collection of the most recently used filters.

Edit Filter

Pivot Grid - Invoke Filter Editor Panel

The button displayed in the image above invokes the Filter Editor:

Pivot Grid - New Filter Editor

API Description
PivotGridControl.AllowFilterEditor Specifies whether to allow users to invoke the Filter Editor from the header area’s context menu and Filter Panel.
PivotGridControl.ShowFilterEditor() Invokes the Filter Editor.

Clear Filter

The Clear Filter button at the end of the Filter Panel removes all filter conditions.

Pivot Grid - Clear Filter

Users can also remove individual conditions as illustrated in the image below:

Pivot Grid - Remove Condition

API Description
PivotGridControl.ResetFilterCriteria() Clears the filter.
FilteringPanelControl.ClearingFilterCommand Gets or sets a command executed when a user clicks the Clear Filter button within the Filter Panel.
FilterPanelClearingFilterEventArgs.Handled Gets or sets whether the built-in clear filter action is canceled.

Example: Intercept Clear Filter Button Clicks

Bind a command to the FilteringPanelControl.ClearingFilterCommand property to intercept the filter clear action in a ViewModel. Assign the command to the new Filter Panel through the PivotGridControl.FilteringPanelStyle property. Set the FilterPanelClearingFilterEventArgs.Handled property to true to cancel the built-in clear action. If the Handled property is false, the built-in clear action runs after the command.

Pivot Grid - Clear Filter Button Command

<dx:ThemedWindow x:Class="FilterPanelExample.MainWindow"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
                 xmlns:dxpg="http://schemas.devexpress.com/winfx/2008/xaml/pivotgrid"
                 xmlns:dxfui="http://schemas.devexpress.com/winfx/2008/xaml/core/filteringui">
    <dxpg:PivotGridControl ShowFilterPanelMode="ShowAlways">
        <dxpg:PivotGridControl.FilteringPanelStyle>
            <Style TargetType="dxfui:FilteringPanelControl">
                <Setter Property="ClearingFilterCommand"
                        Value="{Binding DataContext.ClearingFilterCommandHandler,
                                RelativeSource={RelativeSource AncestorType=Window}}"/>
            </Style>
        </dxpg:PivotGridControl.FilteringPanelStyle>
    </dxpg:PivotGridControl>
</dx:ThemedWindow>

Filter Panel Element Clicks

Bind a command to the FilteringPanelControl.ElementClickCommand property to handle clicks on individual Filter Panel elements in a ViewModel. Assign the command through the PivotGridControl.FilteringPanelStyle property. The command parameter is a FilterPanelElementClickEventArgs object that identifies the clicked element:

ColumnName
Gets the field name associated with the clicked Filter Panel element.
ElementType
Gets the type of the clicked Filter Panel element.
Value
Gets the value or operator associated with the clicked Filter Panel element.
ClickCount
Gets the number of clicks on a Filter Panel element.

Example: Handle Filter Panel Element Clicks

The following example handles clicks on field name and value elements to display a message:

<dx:ThemedWindow x:Class="FilterPanelExample.MainWindow"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
                 xmlns:dxpg="http://schemas.devexpress.com/winfx/2008/xaml/pivotgrid"
                 xmlns:dxfui="http://schemas.devexpress.com/winfx/2008/xaml/core/filteringui">
    <dxpg:PivotGridControl ShowFilterPanelMode="ShowAlways">
        <dxpg:PivotGridControl.FilteringPanelStyle>
            <Style TargetType="dxfui:FilteringPanelControl">
                <Setter Property="ElementClickCommand"
                        Value="{Binding DataContext.ElementClickCommandHandler,
                                RelativeSource={RelativeSource AncestorType=Window}}"/>
            </Style>
        </dxpg:PivotGridControl.FilteringPanelStyle>
    </dxpg:PivotGridControl>
</dx:ThemedWindow>

Customize Appearance

Assign a style to the PivotGridControl.FilteringPanelStyle property to customize the color of individual Filter Panel elements.

Color Mode

Use the FilteringPanelControl.ColorMode property to switch between two color modes:

  • Default — The Filter Panel applies active theme brushes to all elements. You can override these brushes with background and foreground properties for individual elements.

    Pivot Grid - Default Color Mode

  • Plain — The Filter Panel applies the transparent background to all elements and ignores background-specific properties. You can specify foreground brushes for individual elements.

    Pivot Grid - Plain Color Mode

Example: Specify Color Mode

The following example applies the transparent background to all Filter Panel elements and paints field names blue:

Pivot Grid - Color Mode

<dx:ThemedWindow x:Class="FilterPanelExample.MainWindow"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
                 xmlns:dxpg="http://schemas.devexpress.com/winfx/2008/xaml/pivotgrid"
                 xmlns:dxfui="http://schemas.devexpress.com/winfx/2008/xaml/core/filteringui">
    <dxpg:PivotGridControl ShowFilterPanelMode="ShowAlways">
        <dxpg:PivotGridControl.FilteringPanelStyle>
            <Style TargetType="dxfui:FilteringPanelControl">
                <Setter Property="ColorMode" Value="Plain"/>
                <Setter Property="PropertyForeground" Value="Blue"/>
            </Style>
        </dxpg:PivotGridControl.FilteringPanelStyle>
    </dxpg:PivotGridControl>
</dx:ThemedWindow>

Element Colors

Use the following properties to specify background and foreground brushes for individual Filter Panel element types:

API Description
PropertyBackground / PropertyForeground Background and foreground brushes for field names.
ValueBackground / ValueForeground Background and foreground brushes for filter values.
OperatorBackground / OperatorForeground Background and foreground brushes for comparison operators (for example, =, >, <).
LogicalOperatorBackground / LogicalOperatorForeground Background and foreground brushes for logical operators (AND/OR).

Note

When the FilteringPanelControl.ColorMode property is set to Plain, background brushes have no effect. Foreground brushes apply in both color modes.

Example: Specify Filter Panel Element Colors

The following example sets a yellow background for field names:

Pivot Grid - Property Background

<dx:ThemedWindow x:Class="FilterPanelExample.MainWindow"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
                 xmlns:dxpg="http://schemas.devexpress.com/winfx/2008/xaml/pivotgrid"
                 xmlns:dxfui="http://schemas.devexpress.com/winfx/2008/xaml/core/filteringui">
    <dxpg:PivotGridControl ShowFilterPanelMode="ShowAlways">
        <dxpg:PivotGridControl.FilteringPanelStyle>
            <Style TargetType="dxfui:FilteringPanelControl">
                <Setter Property="ColorMode" Value="Default"/>
                <Setter Property="PropertyBackground" Value="Yellow"/>
            </Style>
        </dxpg:PivotGridControl.FilteringPanelStyle>
    </dxpg:PivotGridControl>
</dx:ThemedWindow>

Legacy and New Filter Panels

New Filter Panel

The **new** Filter Panel highlights individual field names, field values, and date-time functions.

Legacy Filter Panel

The **legacy** Filter Panel (Prefilter Panel) displays a filter string.

To display the legacy Filter Panel (Prefilter Panel):

Note

The PivotGridControl bound to an OLAP Data Source displays the legacy Filter Panel.

Filter Panel Keyboard Actions

Set the AllowFilterPanelNavigation property to true to enable keyboard navigation between PivotGridControl cells and the Filter Panel.

Use the following shortcuts to navigate between PivotGridControl and the Filter Panel:

Focused Element Action Keyboard Hotkey
Anywhere in the Pivot Grid Move focus directly to the Filter Panel Ctrl + Shift + F
A Pivot Grid cell Move focus to Filter Panel Ctrl + Tab
A Pivot Grid last cell Move focus to Filter Panel Tab
Filter Panel Move focus to Pivot Grid cells Ctrl + Shift + Tab

Use the following shortcuts to navigate through Filter Panel elements:

Pivot Grid - Filter Panel Anatomy

Focused Element Action Keyboard Hotkey
Enable/Disable Filter check box Toggle filtering Space
Clear Expression button Remove the expression Space or Enter
Clear Expression button Navigate between clear expression buttons and
Most Recently Used Filters button Open the filter list Space or Enter
Most Recently Used Filters item Navigate between filter items and
Most Recently Used Filters item Apply the selected filter Enter
Expand/Collapse Panel button Expand or collapse the Panel Space or Enter
Edit Filter button Open the Filter Editor Space or Enter
Clear Filter button Clear all filter expressions Space or Enter