Skip to main content

PivotGridCustomTotalCollection Class

Represents a collection of custom totals for a field.

Namespace: DevExpress.XtraPivotGrid

Assembly: DevExpress.XtraPivotGrid.v23.2.dll

NuGet Package: DevExpress.Win.PivotGrid

Declaration

public class PivotGridCustomTotalCollection :
    PivotGridCustomTotalCollectionBase

The following members return PivotGridCustomTotalCollection objects:

Remarks

A field’s PivotGridField.CustomTotals property of the PivotGridCustomTotalCollection class represents a collection of custom totals.

The PivotGrid control allows you to display automatic or custom totals for outer column fields and row fields. By default, the field’s PivotGridFieldBase.TotalsVisibility property is set to PivotTotalsVisibility.AutomaticTotals, so automatic totals are displayed. To display custom totals, do the following:

When a sequence of operations is performed each of which affects the control’s appearance, the PivotGrid control updates itself after each such operation. To prevent excessive updates you should enclose the code within calls to the PivotGridControl.BeginUpdate and PivotGridControl.EndUpdate methods. For instance, when setting custom totals for a field via code you can enclose the code within the BeginUpdate and EndUpdate method calls. In this case, the control will be updated only once - by the EndUpdate method.

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();
}

Inheritance

See Also