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

PivotGridField.CustomTotals Property

Gets the current field’s custom total collection.

Namespace: DevExpress.XtraPivotGrid

Assembly: DevExpress.XtraPivotGrid.v19.1.dll

Declaration

[Browsable(true)]
[XtraSerializableProperty(XtraSerializationVisibility.Collection, true, true, true, 0, XtraSerializationFlags.DefaultValue)]
public PivotGridCustomTotalCollection CustomTotals { get; }

Property Value

Type Description
PivotGridCustomTotalCollection

A PivotGridCustomTotalCollection object which represent the custom totals’ collection.

Remarks

The PivotGrid control lets you calculate automatic or custom totals against data fields. These totals are displayed as an additional column(s) for each value in an outer column field and as an additional row for each value in an outer row field.

The CustomTotals collection contains PivotGridCustomTotal objects which represent custom totals for the current field. They are displayed when the field is positioned within the Column Header Area or Row Header Area and only if its PivotGridFieldBase.TotalsVisibility property is set to PivotTotalsVisibility.CustomTotals.

Example

In the following example, four custom totals are added for a ‘Category Name’ row field. They will calculate the total Average, Sum, Min and Max values against the currently displayed data field.

The result is shown below.

PivotGridField_CustomTotals_Ex

using DevExpress.Data.PivotGrid;
using DevExpress.XtraPivotGrid;

// Get a reference to the CategoryName field.
PivotGridField field = pivotGridControl1.Fields["CategoryName"];
pivotGridControl1.BeginUpdate();
try {
   // Clear the custom total collection.
   field.CustomTotals.Clear();
   // Add four items to the custom total collection to calculate the Average, 
   // Sum, Max and Min summaries.
   field.CustomTotals.Add(PivotSummaryType.Average);
   field.CustomTotals.Add(PivotSummaryType.Sum);
   field.CustomTotals.Add(PivotSummaryType.Max);
   field.CustomTotals.Add(PivotSummaryType.Min);
   // Make the custom totals visible for this field.
   field.TotalsVisibility = PivotTotalsVisibility.CustomTotals; 
}
finally {
   pivotGridControl1.EndUpdate();
}
See Also