Filter Editor

  • 3 minutes to read

The Filter Editor allows users to build complex filter criteria. A user can add any number of conditions that apply to individual fields and then use logical operators to build the composite filter expression.

pivot-filter-editor-new

Run Demo: Excel Style Filtering

Invoke the Filter Editor

End users can invoke the Filter Editor in the following ways:

  • Right-click anywhere in the field header area and select Show Filter:

    pivot-filter-editor-invoke-menu

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

    pivot-filter-editor-invoke-panel

To remove the Show Filter Editor item from the context menu and the Edit Filter button from the Filter Panel, set the PivotGridControl.AllowFilterEditor property to false.

To invoke the Filter Editor in code, call the PivotGridControl.ShowFilterEditor method or the PivotGridCommands.ShowFilterEditor command.

Filter Editor UI

The Filter Editor displays filter criteria as a tree structure where nodes are filter conditions. The entire expression is organized as a tree where parent nodes are logical operators that link individual filter conditions.

Filter Editor API

API Description
PivotGridControl.AllowFilterEditor Specifies whether users can invoke the Filter Editor.
PivotGridControl.ShowFilterEditor / PivotGridCommands.ShowFilterEditor Invokes the Filter Editor.
PivotGridControl.HideFilterEditor / PivotGridCommands.HideFilterEditor Hides the Filter Editor.
PivotGridControl.FilterString Gets or sets the filter expression applied to PivotGridControl data.
PivotGridControl.FilterCriteria Gets or sets the filter criteria applied to PivotGridControl data.
PivotGridControl.FilterCriteriaChanged The PivotGridControl raises this event after a filter expression is changed.

Customize the Filter Editor

Customize the Field List

Set the data field’s PivotGridField.ShowInPrefilter property to false to hide the data field from the Filter Editor:

<dxpg:PivotGridControl>
    <dxpg:PivotGridControl.Fields>
        <dxpg:PivotGridField FieldName="Trademark"
                             Area="RowArea"
                             Caption="Trademark"
                             ShowInPrefilter="False"/>
    ...                            
    </dxpg:PivotGridControl.Fields>
</dxpg:PivotGridControl>

Customize the Operator List

NOTE

The complete sample project How to Customize a Filter Editor is available in the DevExpress Examples repository.

Use the PivotGridControl.FilterEditorTemplate property to specify a custom data template. You can also use the PivotGridControl.FilterEditorDialogServiceTemplate property to modify the appearance and functionality of the window that hosts the FilterEditorControl. To customize the list of operators, handle the FilterEditorControl.QueryOperators event. The following code demonstrates how to remove all operators except Between and NotBetween:

<dxpg:PivotGridControl.FilterEditorTemplate>
    <DataTemplate>
        <dxfui:FilterEditorControl QueryOperators="FilterEditorControl_QueryOperators" />
    </DataTemplate>
</dxpg:PivotGridControl.FilterEditorTemplate>
using DevExpress.Xpf.Core.FilteringUI;
// ... 
private void FilterEditorControl_QueryOperators(object sender, FilterEditorQueryOperatorsEventArgs e)
{
    if (e.FieldName == "fieldOrderDate")
    {
        e.Operators.Clear();
        e.Operators.Add(new FilterEditorOperatorItem(FilterEditorOperatorType.Between) { Caption = "Between" });
        e.Operators.Add(new FilterEditorOperatorItem(FilterEditorOperatorType.NotBetween) { Caption = "NotBetween" });
    }
}

Legacy Filter Editor

To use the legacy Filter Editor (Prefilter):