FieldFilterValues.FilterType Property
Gets or sets the field’s filter type.
Namespace: DevExpress.Xpf.PivotGrid
Assembly: DevExpress.Xpf.PivotGrid.v18.2.dll
Declaration
Property Value
Type | Default | Description |
---|---|---|
FieldFilterType | **Excluded** | A FieldFilterType enumeration value which specifies the field’s filter type. |
Available values:
Name | Description |
---|---|
Excluded | Specifies that the DXPivotGrid control should not display the filter values. All the other values will be displayed. |
Included | Specifies that the DXPivotGrid control should display only the filter values. |
Remarks
The FilterType property specifies whether only the records that contain values from the PivotGridFieldFilterValues.Values array of a specific field are displayed in a pivot grid.
If the FilterType property is set to the FieldFilterType.Included value, only the records which contain values from the PivotGridFieldFilterValues.Values array of a specific field are displayed by a pivot grid. Otherwise, if the FilterType property is set to the FieldFilterType.Excluded value, only the records which don’t contain values from the PivotGridFieldFilterValues.Values array of a specific field are displayed.
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’.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-apply-filter-to-a-field-e2134.
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
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the FilterType property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.