Filter Drop-Down
- 3 minutes to read
End users can use a field’s filter drop-down to build a simple filter criterion and apply it to a field.
To invoke a filter drop-down, click a field’s filter button. The filter drop-down contains unique field values. Use the PivotGridField.GetUniqueValues method to get these values in code.
Tip
To create complex filter criteria, use the Filter Editor.
Availability
End-users cannot filter data fields.
To hide filter buttons from all field headers, set the PivotGridControl.AllowFilter property to false. For individual fields, set the PivotGridField.AllowFilter property to false. This does not affect filtering in code.
Note
Excel-style filter drop-down does not work with OLAP data sources.
Drop-down Filter Modes
To switch modes:
for a specific field, set the PivotGridField.FilterPopupMode property.
for all fields, set the PivotGridControl.FieldFilterPopupMode property
Excel (default)
The Excel-style filter drop down contains two tabs:
The Filter Rules tab displays a drop-down list of valid operators for the current field type. This allows you to construct a filter criterion.
The Filter Values tab contains a checklist with the filter values. The shaded numbers in parentheses are record counts.
Feature | Description | API |
---|---|---|
Display only the records that meet the current filter criteria | The filter drop-down contains all the unique field values, although some values do not meet criteria set by other field filters. You can remove unnecessary field values from the filter drop-down. | Set the PivotGridControl.ShowOnlyAvailableFilterItems property to true. |
Requires the installation of a WPF Subscription. Download
Legacy
The drop-down displays a list of values in a checked list box. It is based on the ListBoxEdit control.
Feature | Description | API |
---|---|---|
Display only the records that meet the current filter criteria | The filter drop-down contains all the unique field values, although some values do not meet criteria set by other field filters. You can remove unnecessary field values from the filter drop-down. | Set the PivotGridControl.ShowOnlyAvailableFilterItems property to true. |
Group filter | The group filter filters data against the values of grouped fields. Filter values are hierarchically arranged in a filter drop-down and displayed in a tree list. | Set the PivotGridControl.GroupFilterMode property to GroupFilterMode.Tree. |
Custom Filter Drop-down
To implement a new custom filter and use it instead of the built-in filter drop-down, create a data template and assign it to the The PivotGridField.CustomExcelStyleFilterPopupTemplate property.
The following code snippet uses the CalendarFilterElement to filter the Order Date field values:
<dxpg:PivotGridField
Area="FilterArea"
Caption="OrderDate"
FieldName="OrderDate"
GroupInterval="Date"
Name="fieldOrderDate"
ImmediateUpdateExcelStyleFilter="False">
<dxpg:PivotGridField.CustomExcelStyleFilterPopupTemplate>
<DataTemplate>
<dxfui:CalendarFilterElement Name="PART_FilterElement" />
</DataTemplate>
</dxpg:PivotGridField.CustomExcelStyleFilterPopupTemplate>
</dxpg:PivotGridField>
The image below shows the result:
Note
The complete sample project How to Create a Custom Filter Drop-Down is available in the DevExpress Examples repository.