PivotGridControl.CustomFieldValueCells Event

Allows you to customize field value cells.

Namespace: DevExpress.Xpf.PivotGrid

Assembly: DevExpress.Xpf.PivotGrid.v20.1.dll

Declaration

public event PivotCustomFieldValueCellsEventHandler CustomFieldValueCells
Public Event CustomFieldValueCells As PivotCustomFieldValueCellsEventHandler

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.
Handled Gets or sets a value that indicates the present state of the event handling for a routed event as it travels the route. Inherited from RoutedEventArgs.
IsUpdateRequired Gets whether the area where the field value cells reside needs to be redrawn after the event is handled.
OriginalSource Gets the original reporting source as determined by pure hit testing, before any possible Source adjustment by a parent class. Inherited from RoutedEventArgs.
RoutedEvent Gets or sets the RoutedEvent associated with this RoutedEventArgs instance. Inherited from RoutedEventArgs.
RowCount Gets the number of rows in the pivot grid.
Source Gets or sets a reference to the object that raised the event. Inherited from RoutedEventArgs.

Remarks

The CustomFieldValueCells event occurs when the layout of the PivotGridControl 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 PivotCustomFieldValueCellsEventArgs.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 PivotCustomFieldValueCellsEventArgs.SetGrandTotalLocation method. To obtain the current location of grand total headers, use the PivotCustomFieldValueCellsEventArgs.GetGrandTotalLocation method.

When handling the CustomFieldValueCells event, you can remove individual cells with their nested columns and rows via the PivotCustomFieldValueCellsEventArgs.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 PivotGridControl.CustomCellValue, PivotGridControl.CustomSummary and PivotGridControl.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, the CustomFieldValueCells event 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).

<Window xmlns:dxpg="http://schemas.devexpress.com/winfx/2008/xaml/pivotgrid" 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        x:Class="DXPivotGrid_SplittingCells.Window1" 
        dx:ThemeManager.ThemeName="LightGray" 
        Height="580" Width="1200"
        Loaded="Window_Loaded"
        Title="Window1">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <dxpg:PivotGridControl Grid.Row="1" Margin="2,2,2,0" Name="pivotGrid" AllowDrag="False"
                               FieldValueDisplayText="pivotGrid_FieldValueDisplayText" 
                               AllowFilter="False"/>
        <GroupBox Grid.Row="0" Height="Auto" Margin="2,2,2,0"
                  Name="groupBox1" VerticalAlignment="Bottom">
            <StackPanel Orientation="Vertical">
                <RadioButton x:Name="rbDefault" IsChecked="True" Content="Default Layout"
                             Margin="0,0,0,2" Checked="rbDefault_Checked"/>
                <RadioButton Checked="rbDefault_Checked" Margin="0,2,0,0"
                             Content="Split Grand Total Column Header"/>
            </StackPanel>
        </GroupBox>
    </Grid>
</Window>   
See Also