PivotGridControl.CustomFilterPopupItems Event
Allows you to customize the Legacy filter drop-down list items.
Namespace: DevExpress.Xpf.PivotGrid
Assembly: DevExpress.Xpf.PivotGrid.v24.1.dll
NuGet Package: DevExpress.Wpf.PivotGrid
Declaration
Event Data
The CustomFilterPopupItems event's data class is PivotCustomFilterPopupItemsEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Field | Gets the field for which the event has been raised. |
Handled | Gets or sets a value that indicates the present state of the event handling for a routed event as it travels the route. Inherited from RoutedEventArgs. |
Items | Gets the collection of filter items. |
OriginalSource | Gets the original reporting source as determined by pure hit testing, before any possible Source adjustment by a parent class. Inherited from RoutedEventArgs. |
RoutedEvent | Gets or sets the RoutedEvent associated with this RoutedEventArgs instance. Inherited from RoutedEventArgs. |
ShowBlanksItem | Gets the ‘Show Blanks’ filter item. |
Source | Gets or sets a reference to the object that raised the event. Inherited from RoutedEventArgs. |
The event data class exposes the following methods:
Method | Description |
---|---|
CheckAllItems(Boolean) | Checks or unchecks all filter items in the PivotCustomFilterPopupItemsEventArgs.Items collection. |
InvokeEventHandler(Delegate, Object) | When overridden in a derived class, provides a way to invoke event handlers in a type-specific way, which can increase efficiency over the base implementation. Inherited from RoutedEventArgs. |
OnSetSource(Object) | When overridden in a derived class, provides a notification callback entry point whenever the value of the Source property of an instance changes. Inherited from RoutedEventArgs. |
Remarks
Important
The CustomFilterPopupItems event is raised only for the Legacy filter drop-down.
The CustomFilterPopupItems event is raised when an end-user invokes the filter drop-down list. The event parameter’s PivotCustomFilterPopupItemsEventArgs.Items property returns a collection of filter items. Elements of the collection are represented by the PivotGridFilterItem objects. Initially, the filter items collection contains items representing the unique values stored in the underlying data source, in the current field. To hide particular items from the filter drop-down, remove them from the collection.
You can also specify the check state of filter items using their PivotGridFilterItem.IsChecked property. The event parameter provides the PivotCustomFilterPopupItemsEventArgs.CheckAllItems method, which allows you to specify the check state of all filter items in the collection.
To obtain the field for which the filter drop-down is being populated, use the event parameter’s PivotCustomFilterPopupItemsEventArgs.Field property.
The filter drop-down list contains the ‘Show Blanks’ item, used to control whether the data records that contain null values in the respective field are processed by the pivot grid. To access the ‘Show Blanks’ filter item, use the PivotCustomFilterPopupItemsEventArgs.ShowBlanksItem property.
Note
In the OLAP mode, the PivotCustomFilterPopupItemsEventArgs.ShowBlanksItem property returns null.
Example
The following example shows how to add and remove items from the filter dropdown list.In this example, the 'Beverages' item is hidden from the filter dropdown list of the Category field, and a dummy item is created and added to the list. To do this, the CustomFilterPopupItems event is handled. In the event handler, the 'Beverages' item is removed from the event parameter's Items collection, and a new item ('Dummy Item') is added to the collection.
using System.Windows;
using DevExpress.Xpf.PivotGrid;
using DevExpress.XtraPivotGrid.Data;
using DXPivotGrid_CustomFilterItems.DataSet1TableAdapters;
namespace DXPivotGrid_CustomFilterItems {
public partial class MainWindow : Window {
DataSet1.ProductReportsDataTable productReportsDataTable =
new DataSet1.ProductReportsDataTable();
ProductReportsTableAdapter productReportsDataAdapter = new ProductReportsTableAdapter();
public MainWindow() {
InitializeComponent();
pivotGridControl1.DataSource = productReportsDataAdapter.GetData();
}
readonly string dummyItem = "";
private void pivotGridControl1_CustomFilterPopupItems(object sender,
PivotCustomFilterPopupItemsEventArgs e) {
if (object.ReferenceEquals(e.Field, fieldCategoryName)) {
for (int i = e.Items.Count - 1; i >= 0; i--) {
if (object.Equals(e.Items[i].Value, "Beverages")) {
e.Items.RemoveAt(i);
break;
}
}
e.Items.Insert(0, new PivotGridFilterItem(dummyItem,
"Dummy Item",
e.Field.FilterValues.Contains(dummyItem)));
}
}
}
}