ASPxPivotGrid.CustomFieldValueCells Event

Allows you to customize field value cells.

Namespace: DevExpress.Web.ASPxPivotGrid

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

Declaration

public event EventHandler<PivotCustomFieldValueCellsEventArgs> CustomFieldValueCells
Public Event CustomFieldValueCells As EventHandler(Of PivotCustomFieldValueCellsEventArgs)

Event Data

The CustomFieldValueCells event handler receives an argument of the PivotCustomFieldValueCellsEventArgs type. The following properties provide information specific to this event.

Property Description
ColumnCount Gets the number of columns in the pivot grid.
IsUpdateRequired Gets whether the area where the field value cells reside needs to be redrawn after the event is handled.
RowCount Gets the number of rows in the pivot grid.

Remarks

The CustomFieldValueCells event occurs when the layout of the ASPxPivotGrid is changed, allowing you to customize column and row headers: field value cells, data field, total and grand total headers.

Use the event parameter's PivotCustomFieldValueCellsEventArgs.GetCell method to obtain data related to an individual cell, by its index. This method returns a FieldValueCell object, which provides the data. Use the PivotCustomFieldValueCellsEventArgsBase.GetCellCount method to obtain the total number of field value cells. Column/row headers can also be identified by their column/row. Use the PivotCustomFieldValueCellsEventArgs.FindCell method to obtain the header whose column/row matches a specific condition.

The CustomFieldValueCells event allows you to specify the location of grand total headers using the PivotCustomFieldValueCellsEventArgsBase.SetGrandTotalLocation method. To obtain the current location of grand total headers, use the PivotCustomFieldValueCellsEventArgsBase.GetGrandTotalLocation method.

When handling the CustomFieldValueCells event, you can also remove individual cells with their nested columns and rows via the PivotCustomFieldValueCellsEventArgsBase.Remove method.

The PivotCustomFieldValueCellsEventArgs.Split method allows you to split field value cells that have more than one nested cell. This method splits cells that match the specified condition (or, optionally, only the first matching cell) in a custom manner defined by the FieldValueSplitData objects.

Note

Custom values provided via the ASPxPivotGrid.CustomCellValue, ASPxPivotGrid.CustomSummary and ASPxPivotGrid.CustomCellDisplayText events are not available when handling the CustomFieldValueCells event, because it is raised prior to these events.

Examples

The following example demonstrates how to split field value cells. In this example, the Grand Total column header is split into two cells: Price and Count. To do this, handle the CustomFieldValueCells event and use the event parameter's Split method. Cells that should be split are identified by a predicate that returns true for those cells. The quantity, size and captions of newly created cells are specified by an array of cell definitions (the FieldValueSplitData objects).

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
    Inherits="ASPxPivotGrid_SplittingCells._Default" %>
<%@ Register Assembly="DevExpress.Web.ASPxPivotGrid.v10.2, Version=10.2.0.0,
    Culture=neutral, PublicKeyToken=79868b8147b5eae4"
    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 id="Head1" runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:RadioButtonList ID="radioButtonList" runat="server"
            AutoPostBack="true" CellSpacing="10" >
            <asp:ListItem Selected="True">Default Layout</asp:ListItem>
            <asp:ListItem>Split Grand Total Column Header</asp:ListItem>
        </asp:RadioButtonList>
        <br />
        <div>
            <dx:ASPxPivotGrid ID="pivotGrid" runat="server" Width="500px" 
                OnFieldValueDisplayText="pivotGrid_FieldValueDisplayText"
                OnCustomFieldValueCells="pivotGrid_CustomFieldValueCells"
                OptionsCustomization-AllowFilter="False"
                OptionsCustomization-AllowDrag="False">
            </dx:ASPxPivotGrid>
        </div>
    </form>    
</body>

</html>
See Also