Filter Editor

  • 2 minutes to read

The Filter Editor provides a visual interface that allows end users to create and edit filter criteria. The Filter Editor displays filter criteria as a tree where logical operators combine individual nodes that specify filter conditions.

pivot-filter-editor-new

TIP

Demo: Filtering

Requires installation of WPF Subscription. Download.

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 invoke the Filter Editor in code, call the PivotGridControl.ShowPrefilter() method.

Availability

NOTE

The Filter Editor based on the FilterEditorControl and described in this article is introduced in v19.1. Previous versions use the Prefilter Editor based on the FilterControl. To switch to the Prefilter Editor, set the PivotGridControl.UseLegacyFilterEditor property to true.

To remove the Show Filter command from the context menu, set the PivotGridControl.AllowPrefilter property to false.

Customize the Filter Editor

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" });
    }
}