Skip to main content

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.v23.2.Core.dll

NuGet Packages: DevExpress.PivotGrid.Core, DevExpress.Win.Navigation

Declaration

[DefaultValue(PivotTotalsVisibility.AutomaticTotals)]
public PivotTotalsVisibility TotalsVisibility { get; set; }

Property Value

Type Default Description
PivotTotalsVisibility AutomaticTotals

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

Available values:

Name Description
AutomaticTotals

Specifies that automatic totals are calculated.

CustomTotals

Specifies that custom totals are calculated using the formula in the PivotGridField.CustomTotals collection.

None

Specifies that a summary total is not calculated.

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.

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

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the TotalsVisibility property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also