Skip to main content

ASPxPivotGrid.CustomFilterPopupItems Event

Allows you to customize the filter drop-down list items.

Namespace: DevExpress.Web.ASPxPivotGrid

Assembly: DevExpress.Web.ASPxPivotGrid.v24.1.dll

NuGet Package: DevExpress.Web

Declaration

public event EventHandler<PivotCustomFilterPopupItemsEventArgs> CustomFilterPopupItems

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.
Items Gets the collection of filter items.
ShowBlanksItem Gets the ‘Show Blanks’ filter item.

The event data class exposes the following methods:

Method Description
CheckAllItems(Boolean) Checks or unchecks all filter items in the PivotCustomFilterPopupItemsEventArgs.Items collection.

Remarks

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

UPD: This example is obsolete**.

Starting with v11.2, set the ShowOnlyAvailableItems property to true to hide filter items whose corresponding field values are not displayed.

The following example shows how to hide filter items whose corresponding field values are not displayed.In this example, the Row Header Area of the PivotGrid contains two fields: 'Category Name' and 'Product Name'. If an end-user hides a particular product category via the 'Category Name' field's filter drop-down, the corresponding products will be excluded from the filter drop-down of the 'Product Name' field. To hide filter items, the CustomFilterPopupItems event is handled.

<dx:ASPxPivotGrid ID="ASPxPivotGrid1" runat="server" DataSourceID="AccessDataSource1"
        OnCustomFilterPopupItems="ASPxPivotGrid1_CustomFilterPopupItems">
    <Fields>
        <dx:PivotGridField ID="fieldProductName" Area="RowArea" AreaIndex="1"
        Caption="Product Name" FieldName="ProductName">
        </dx:PivotGridField>
        <dx:PivotGridField ID="fieldShippedYear" Area="ColumnArea" AreaIndex="0" Caption="Year"
            FieldName="ShippedDate" GroupIndex="0" GroupInterval="DateYear" InnerGroupIndex="0"
            UnboundFieldName="fieldShippedDate">
        </dx:PivotGridField>
        <dx:PivotGridField ID="fieldProductSales" Area="DataArea" AreaIndex="0" Caption="Sales"
            FieldName="ProductSales">
        </dx:PivotGridField>
        <dx:PivotGridField ID="fieldCategoryName" Area="RowArea" AreaIndex="0"
        Caption="Category Name" FieldName="CategoryName">
        </dx:PivotGridField>
        <dx:PivotGridField ID="fieldShippedMonth" Area="ColumnArea" AreaIndex="2" Caption="Month"
            FieldName="ShippedDate" GroupIndex="0" InnerGroupIndex="2" GroupInterval="DateMonth">
        </dx:PivotGridField>
        <dx:PivotGridField ID="fieldShippedQuarter" Area="ColumnArea" AreaIndex="1"
        Caption="Quarter" FieldName="ShippedDate" GroupIndex="0"
        GroupInterval="DateQuarter" InnerGroupIndex="1" 
        ValueFormat-FormatString="Quarter {0}"
        ValueFormat-FormatType="Custom">
        </dx:PivotGridField>
    </Fields>
    <Groups>
        <dx:PivotGridWebGroup />
    </Groups>
</dx:ASPxPivotGrid>
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/nwind.mdb"
    SelectCommand="SELECT [CategoryName], [ProductName], [ProductSales],
    [ShippedDate] FROM [ProductReports]">
</asp:AccessDataSource>
See Also