Group Filtering

  • 3 min to read

The group filtering allows end users to filter the Pivot Grid's data against groups of fields.

Field Filter Limitations

The field filter contains a collection of filter values. Each of the filter values corresponds to a unique value stored in the underlying data source in the current field. Depending on the filter type, the pivot grid shows only those rows and columns that contain the filter values in the corresponding fields, or hides those rows and columns. See Filtering Basics for details.

The field filter has little effect when used to filter data against the grouped fields. These fields are hierarchically arranged, while the field filter performs filtering based on the values of individual fields, and does not take into account the field hierarchy. For more information about groups, see Field Groups.

The image below shows the PivotGridControl, whose Column Header Area contains two fields: 'Year' and 'Quarter'.


The field filter can hide all 'Qtr3' columns, but it cannot hide the individual column corresponding to 'Qtr3 2014'. The group filter is introduced to solve the problem.

Group Filtering Mechanism

The group filter filters data against the values of grouped fields and manages a collection of group filter values. The PivotGroupFilterValues.Values property provides access to group filter values. Each of the filter values corresponds to a field value from one of the grouped fields.

Similarly to the values of grouped fields, the group filter values are hierarchically arranged. The PivotGroupFilterValues.Values collection contains values from the first field in the group (first-level values). Each of the first-level values holds a collection of values from the second field in the group (child values), and etc.

The group filter values are used to define which data source records should be processed by the pivot grid control. A group filter value corresponds to a data source record if the following conditions are met:

  • The data source record contains the group filter value in the respective field.
  • The data source record contains the group filter value's ancestor values in the respective fields.
  • The group filter value does not contain child values.

If the GroupFilterValues.FilterType property is set to FieldFilterType.Included, only the data source records that correspond to one of the filter values are processed. For the FieldFilterType.Excluded filter type, the data source records that do not correspond to any filter value are processed.

The image below shows the PivotGridControl with the filter drop-down invoked for the 'Year-Quarter' group. The filter values collection contains a '2015' value, which has the 'Qtr2' and 'Qtr4' child values, and the filter type is set to FieldFilterType.Excluded. As a result, the columns that correspond to the 'Qtr2' and 'Qtr4' 2015 are hidden, while the 'Qtr2' column for 2016 is displayed.


Using the Group Filter

The group filter condition is the GroupFilterValues object stored in the group's PivotGridGroup.FilterValues property. To apply a group filter in code, specify the appropriate filter type with the GroupFilterValues.FilterType property, and add filter values to the PivotGroupFilterValues.Values collection.

The group filter can be disabled using the PivotGridControl.GroupFilterMode property. By default, the property is set to GroupFilterMode.Tree. To disable the group filter, set the PivotGridControl.GroupFilterMode property to GroupFilterMode.List. In this instance, pivot grid data will be filtered against grouped fields using the standard field filter.

Regardless of the currently selected group filter mode, you can customize in code both group and field filters. The customizations made for the currently unused field filter take effect when you turn the group filter off.

End users can use the group filter drop-down to apply, remove, and change group filters.



How to: Implement the Group Filter