PivotCustomFilterPopupItemsEventArgs.Items Property
Gets the collection of filter items.
Namespace: DevExpress.XtraPivotGrid
Assembly: DevExpress.XtraPivotGrid.v24.2.dll
NuGet Package: DevExpress.Win.PivotGrid
#Declaration
public IList<PivotGridFilterItem> Items { get; }
#Property Value
Type | Description |
---|---|
IList<Pivot |
A list of Pivot |
#Remarks
Initially, the Items collection contains items representing the unique values stored in the underlying data source in the current field. To hide individual items from the filter dropdown, remove the respective elements from the Items collection.
To obtain the field for which the event has been raised, use the PivotCustomFilterPopupItemsEventArgs.Field property.
#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;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraPivotGrid;
using DevExpress.XtraPivotGrid.Data;
namespace EmptyWinApp {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e) {
this.productReportsTableAdapter.Fill(this.productReports._ProductReports);
}
readonly object dummyItem = new object();
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)));
}
}
}
}