Skip to main content

ASPxPivotGrid.FieldFilterChanging Event

Allows you to customize the filter that is being applied or cancel filtering.

Namespace: DevExpress.Web.ASPxPivotGrid

Assembly: DevExpress.Web.ASPxPivotGrid.v23.2.dll

NuGet Package: DevExpress.Web

Declaration

public event PivotFieldFilterChangingEventHandler FieldFilterChanging

Event Data

The FieldFilterChanging event's data class is PivotFieldFilterChangingEventArgs. The following properties provide information specific to this event:

Property Description
Cancel Gets or sets whether to cancel changing the filter condition.
Field Gets the field being processed. Inherited from PivotFieldEventArgsBase<T>.
FilterType Gets the current filter type.
Values Gets the collection of filter values about to be assigned to the filter.

Remarks

The FieldFilterChanging event occurs before a field’s filter condition is changed. To obtain the collection of filter values which is about to be assigned to the filter, use the event parameter’s PivotFieldFilterChangingEventArgs.Values property. To cancel changing the current filter values collection, set the PivotFieldFilterChangingEventArgs.Cancel property to true. You can also obtain the field for which the filter condition is being changed, and the current filter type using the event parameter’s PivotFieldEventArgsBase<T>.Field and PivotFieldFilterChangingEventArgs.FilterType properties, respectively.

After the filter condition has been changed, the ASPxPivotGrid.FieldFilterChanged event is fired.

Note

To remove default filter items and add custom items instead, use the ASPxPivotGrid.CustomFilterPopupItems event.

Example

The following example shows how to prevent end-users from changing the filter condition.In this example, the FieldFilterChanging event is handled to prevent an end-user from hiding the 'Beverages' field value. If an end-user tries to hide the 'Beverages' field value, the event handler sets the event parameter's Cancel property to true to cancel changing the filter condition.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
    Inherits="ASPxPivotGrid_CancelFilterChange._Default" %>
<%@ Register Assembly="DevExpress.Web.ASPxPivotGrid.v10.2, Version=10.2.4.0,
    Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxPivotGrid"
    TagPrefix="dx" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <dx:ASPxPivotGrid ID="ASPxPivotGrid1" runat="server" DataSourceID="AccessDataSource1"
        OnFieldFilterChanging="ASPxPivotGrid1_FieldFilterChanging">
            <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" GroupInterval="DateYear" InnerGroupIndex="0">
                </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>
            </Fields>
        </dx:ASPxPivotGrid>
        <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/nwind.mdb"
            SelectCommand="SELECT [CategoryName], [ProductName], [ProductSales],
            [ShippedDate] FROM [ProductReports]">
        </asp:AccessDataSource>
    </div>
    </form>
</body>
</html>
See Also