Skip to main content
A newer version of this page is available. .

Prefilter

  • 3 minutes to read

The Prefilter feature serves two purposes. First, it enables PivotGridControl to display a Filter Editor, allowing an end-user to apply filtering to the pivot grid’s underlying data source at runtime. Second, you can filter the underlying data source in code, without displaying a Filter Editor to end-users.

Note

The Prefilter is not supported in OLAP mode.

Filter Editor

The Filter Editor enables end-users to build complex filter criteria with an unlimited number of filter conditions, combined by logical operators. The resulting filter condition will be combined with the field-based filter criteria using the AND Boolean operator. The Filter Editor provides a set of logical operators that significantly simplify the process of creating filters for text, numeric and date-time fields.

End-users can invoke the Filter Editor at runtime via a context menu.

pivotgrid_prefilter

To disable access to the Filter Editor via the context menu, set the PivotGridControl.AllowPrefilter property to false. In this instance, the Show Prefilter context menu item will be hidden, and you will be able to show the Filter Editor using the PivotGridControl.ShowPrefilter method.

Prefilter Panel

When the PivotGridControl.AllowPrefilter option is enabled, and a filter condition is specified, PivotGridControl displays a Prefilter Panel:

PrefilterPanel_Elements

The Prefilter Panel displays a filter expression, an MRU filter button used to display the most recently used Prefilter criteria, an edit button used to invoke a Filter Editor, a check box used to temporarily enable/disable the filtering, and a clear button used to reset the current filter condition. To make this panel always visible or always hidden, use the PivotGridControl.ShowPrefilterPanelMode property.

Using Prefilter in Code

The Prefilter allows you to access its settings and specify filter criteria in code. You can use the following properties and methods to do this:

PivotGridControl.PrefilterCriteria

PivotGridControl.PrefilterString

Gets or sets a filter expression.

PivotGridControl.IsPrefilterEnabled

Gets or sets whether or not the filter specified by the Prefilter is enabled.

PivotGridControl.IsPrefilterVisible

Gets whether or not the Prefilter is invoked.

PivotGridControl.ShowPrefilter

PivotGridControl.HidePrefilter

Invokes/hides the Filter Editor.

PivotGridControl.AllowPrefilter

Gets or sets whether end-users are allowed to invoke the Prefilter.

When you create a filter expression in code, use the PivotGridField.PrefilterColumnName property to refer to a field. The sample below shows how to do this.

pivotGridControl1.PrefilterString = "[" + fieldCategory.PrefilterColumnName + "] Like 'B%'";

Note

The Prefilter cannot filter data against data fields. If a data field is used in filter criteria that has been specified in code, an error message will be displayed within the Prefilter Panel. This message also appears if filter criteria contains a field name that does not exist.

After a filter condition has been changed via a Filter Editor or in code, the PivotGridControl.PrefilterCriteriaChanged event is raised.

To learn more about filter criteria syntax, see Pivot Grid Expression Syntax.

See Also