Tag

PivotGridFieldBase.TotalsVisibility Property

Gets or sets whether to display totals for the current field when it is in the Column Header Area or Row Header Area and if so, whether they are automatic or custom.

Namespace: DevExpress.XtraPivotGrid

Assembly: DevExpress.PivotGrid.v19.2.Core.dll

Declaration

[DefaultValue(PivotTotalsVisibility.AutomaticTotals)]
public PivotTotalsVisibility TotalsVisibility { get; set; }
<DefaultValue(PivotTotalsVisibility.AutomaticTotals)>
Public Property TotalsVisibility As PivotTotalsVisibility

Property Value

Type Default Description
PivotTotalsVisibility

AutomaticTotals

A PivotTotalsVisibility value that specifies which totals are displayed for the current field.

Remarks

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

For each data field a single automatic total is calculated, and its summary function is determined by the field's PivotGridFieldBase.SummaryType property. The number of automatic totals displayed for each value of an outer field matches the number of data fields.

Custom totals allow you to calculate multiple totals against each data field. A custom total is represented by the PivotGridCustomTotal class and its PivotGridCustomTotalBase.SummaryType property identifies the summary function type used to calculate the total.

To display custom totals instead of the automatic totals for the values of an outer column or row field, you should do the following:

If the TotalsVisibility property of an outer column or row field is set to PivotTotalsVisibility.None neither an automatic nor custom total is displayed for the values of this field.

NOTE

The row fields' TotalsVisibility properties are ignored when the PivotGridOptionsViewBase.RowTotalsLocation property is set to PivotRowTotalsLocation.Tree.

Examples

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