Back to Devexpress

Hide Column Totals

wpf-8029-controls-and-libraries-pivot-grid-examples-binding-to-data-how-to-display-unbound-data-in-a-pivotgrid-control.md

latest1.6 KB
Original Source

Hide Column Totals

  • Mar 06, 2023

This example demonstrates how to handle the CustomCellValue event to hide the Discount field grand totals.

View Example: Pivot Grid for WPF - Hide Column Totals

cs
private void PivotGridControl1_CustomCellValue(object sender,PivotCellValueEventArgs e) {
    if (e.ColumnValueType == FieldValueType.GrandTotal
           && e.DataField == fieldDiscount)
        e.Value = null;
}
vb
Private Sub PivotGridControl1_CustomCellValue(ByVal sender As Object, ByVal e As PivotCellValueEventArgs)
    If e.ColumnValueType = FieldValueType.GrandTotal AndAlso e.DataField Is fieldDiscount Then
        e.Value = Nothing
    End If
End Sub
xaml
<dxpg:PivotGridControl DataProcessingEngine="Optimized" 
                       Name="pivotGridControl1" 
                       CustomCellValue="PivotGridControl1_CustomCellValue">
        <dxpg:PivotGridControl.Fields>
        <!-- ... -->
        <dxpg:PivotGridField Name="fieldDiscount" Area="DataArea" CellFormat="p">
            <dxpg:PivotGridField.DataBinding>
                <dxpg:DataSourceColumnBinding ColumnName="Discount"/>
            </dxpg:PivotGridField.DataBinding>
        </dxpg:PivotGridField>
        <!-- ... -->
    </dxpg:PivotGridControl.Fields>
</dxpg:PivotGridControl>