Skip to main content

How to: Implement the Group Filter

  • 2 minutes to read

This example demonstrates how to apply custom group filters to PivotGridControl data.

In this example, a filter type is defined by setting the PivotGroupFilterValues.FilterType property to PivotFilterType.Included. To create and add group filter values to the PivotGroupFilterValues.Values and PivotGroupFilterValue.ChildValues collections the PivotGroupFilterValuesCollection.Add method is used.

View Example

Imports Microsoft.VisualBasic
Imports System.Windows
Imports GroupFilter.nwindDataSetTableAdapters
Imports DevExpress.Xpf.PivotGrid

Namespace GroupFilter
    Partial Public Class MainWindow
        Inherits Window
        Public Sub New()
            Dim salesPersonDataAdapter As New SalesPersonTableAdapter()

            ' Binds the pivot grid to data.
            pivotGridControl1.DataSource = salesPersonDataAdapter.GetData()

            ' Creates a group and adds two fields to it.
            Dim OrderDateGroup As PivotGridGroup = pivotGridControl1.Groups.Add( _
                pivotGridControl1.Fields(2), pivotGridControl1.Fields(3))

            ' Locks the PivotGroupFilterValues object by disabling visual updates.

            ' Sets a filter type. 
            ' It specifies that the PivotGridControl should display only filter values.
            OrderDateGroup.FilterValues.FilterType = FieldFilterType.Included

            ' Creates a filter value and adds it to the PivotGroupFilterValues.Values collection.

            ' Creates a filter value and adds it to the PivotGroupFilterValues.Values collection.
            ' Then creates a child value of the filter value and adds it to the parent value 
            ' collection.

            ' Unlocks the PivotGroupFilterValues object.
        End Sub
    End Class
End Namespace