Skip to main content
A newer version of this page is available. .

ASPxPivotGrid.CustomFieldValueCells Event

Allows you to customize field value cells.

Namespace: DevExpress.Web.ASPxPivotGrid

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

Declaration

public event EventHandler<PivotCustomFieldValueCellsEventArgs> CustomFieldValueCells

Event Data

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

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

The event data class exposes the following methods:

Method Description
FindAllCells(Boolean, Predicate<Object[]>)
FindCell(Boolean, Predicate<Object[]>) Returns the header of the column/row whose summary values match the specified condition.
GetCell(Boolean, Int32) Returns the field value cell by its index.
GetCellCount(Boolean) Returns the number of field value cells in the specified area. Inherited from PivotCustomFieldValueCellsEventArgsBase.
GetCellValue(Int32, Int32) Gets the value of a data cell by its column and row indexes. Inherited from PivotCustomFieldValueCellsEventArgsBase.
GetGrandTotalLocation(Boolean) Returns the location of Grand Total columns or rows. Inherited from PivotCustomFieldValueCellsEventArgsBase.
GetLevelCount(Boolean) Returns the number of column or row levels. Inherited from PivotCustomFieldValueCellsEventArgsBase.
Remove(FieldValueCellBase) Removes the specified field value cell. Inherited from PivotCustomFieldValueCellsEventArgsBase.
SetGrandTotalLocation(Boolean, GrandTotalLocation) Sets the location of Grand Total columns or rows to the specified value. Inherited from PivotCustomFieldValueCellsEventArgsBase.
Split(Boolean, Predicate<FieldValueCell>, FieldValueSplitData[]) Splits all field value cells that match the specified condition.
Split(Boolean, Predicate<FieldValueCell>, Boolean, FieldValueSplitData[]) Splits all field value cells that match the specified condition, or only the first matching cell.
Split(Boolean, Predicate<FieldValueCell>, Boolean, IList<FieldValueSplitData>) Splits all field value cells that match the specified condition, or only the first matching cell.
Split(Boolean, Predicate<FieldValueCell>, IList<FieldValueSplitData>) Splits all field value cells that match the specified condition.

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.

Example

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, the CustomFieldValueCellsevent is handled, and the event parameter’s Split method is used. 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