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

FieldFilterValues Class

Contains filter values for a specific field.

Namespace: DevExpress.Xpf.PivotGrid

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

Declaration

public class FieldFilterValues :
    PivotGridFieldFilterValues

The following members return FieldFilterValues objects:

Remarks

A field’s PivotGridField.FilterValues property of the FieldFilterValues class gives the ability to apply a filter to a field, i.e. select which of the records should be processed by the PivotGrid control. A filter specified by the PivotGridField.FilterValues property is in effect for filter fields, column fields and row fields.

The FieldFilterValues class stores filter values for a specific field. The filtering functionality is dependant upon the FieldFilterValues.FilterType property’s value. It specifies whether the filter values should be displayed in or removed from the PivotGrid control.

If the FieldFilterValues.FilterType property is set to FieldFilterType.Included, the FieldFilterValues class stores the values which should be displayed within the control. In this instance, the PivotGrid control will only process those records that contain filter values in the corresponding field.

If the FieldFilterValues.FilterType property is set to FieldFilterType.Excluded, the FieldFilterValues class stores the values which will not be displayed within the control. In this instance, the PivotGrid control will only process those records that do not contain filter values in the corresponding field.

To add values to and remove them from the filter value list use the PivotGridFieldFilterValues.Add and PivotGridFieldFilterValues.Remove methods.

Specific fields can contain Null (or DBNull) values. The PivotGridFieldFilterValues.ShowBlanks property determines whether the records which contain Null values should be processed by the control. If this property is set to false summaries are not calculated against such records.

An end-user can apply a filter to a field via the filter dropdown. It can be activated by clicking the field’s Filter Button. When an end-user checks/unchecks items within the filter dropdown this automatically modifies the filter value collection.

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

Inheritance

See Also