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

PivotGridField.FilterValues Property

Gets the filter values for the current field.

Namespace: DevExpress.Xpf.PivotGrid

Assembly: DevExpress.Xpf.PivotGrid.v18.2.dll

Declaration

[Browsable(false)]
public FieldFilterValues FilterValues { get; }

Property Value

Type Description
FieldFilterValues

A FieldFilterValues object which contains filter values for the current field.

Remarks

The FilterValues property can be used to specify which of the records in the data source should be displayed and used to calculate summaries within the DXPivotGrid control. The PivotGridFieldFilterValues.Values property defines an array of filter values.

If the FieldFilterValues.FilterType property is set to FieldFilterType.Excluded the records in the data source which contain filter values in the current field are not processed by the DXPivotGrid control.

If the FieldFilterValues.FilterType property is set to FieldFilterType.Included only the records which contain filter values in the current field are processed by the DXPivotGrid control.

An end-user automatically modifies the filter values collection when checking/unchecking specific items via the field’s filter dropdown.

Example

This example shows how to apply a filter to a field. For this, a new FilterFieldValues method was created.

The first condition will select records which contain ‘UK’ in the ‘fieldCountry’ field. The second condition will filter the ‘Category’ field to display only four categories: ‘Beverages’, ‘Condiments’, ‘Seafood’, and ‘Produce’.

Imports System.Windows
Imports System
Imports DevExpress.Xpf.PivotGrid
Imports System.Collections.Generic

Namespace WpfPivotGridFilterValues
    ''' <summary>
    ''' Interaction logic for MainWindow.xaml
    ''' </summary>
    Partial Public Class MainWindow
        Inherits Window

        Public Sub New()
            InitializeComponent()

            ' Filters values in the Country field using the created method.
            FilterFieldValues(fieldCountry,
                  New String() {"UK"}, FieldFilterType.Included)

            ' Filters values in the Category field using the created method.
            FilterFieldValues(fieldCategory,
                  New String() {"Beverages", "Condiments", "Seafood", "Produce"}, FieldFilterType.Included)
        End Sub

        ' Creates a new method that allows filtering field values.
        Private Function FilterFieldValues(ByVal field As PivotGridField,
                                           ByVal filterValues() As Object,
                                           ByVal filterType As FieldFilterType) As Object()
            ' Locks the control to prevent its excessive updates when multiple properties are modified.
            pivotGridControl1.BeginUpdate()
            Try
                ' Clears the filter value collection and adds object items to it.
                field.FilterValues.Clear()
                For Each filterValue As Object In filterValues
                    field.FilterValues.Add(filterValue)
                Next filterValue
            Finally
                ' Specifies that the control should only display records 
                ' which contain the specified values in the field.
                field.FilterValues.FilterType = filterType

                ' Unlocks the control.
                pivotGridControl1.EndUpdate()
            End Try
            Return filterValues
        End Function
    End Class
End Namespace
See Also