Back to Devexpress

GridColumnTotal Class

dashboard-devexpress-dot-dashboardcommon-a7e27bc7.md

latest5.6 KB
Original Source

GridColumnTotal Class

A total calculated based on Grid column values.

Namespace : DevExpress.DashboardCommon

Assembly : DevExpress.Dashboard.v25.2.Core.dll

NuGet Package : DevExpress.Dashboard.Core

Declaration

csharp
public class GridColumnTotal
vb
Public Class GridColumnTotal

The following members return GridColumnTotal objects:

Remarks

The Grid dashboard item allows you to calculate totals against values displayed in the specified column and show these totals under the column. To create a total for the required column, do the following.

  • Create the GridColumnTotal object and specify the type of summary function used to calculate a total using the GridColumnTotal.TotalType property.
  • Add the resulting GridColumnTotal object to the GridColumnBase.Totals collection. Note that you can add any number of totals for each column.

Note that different sets of summary functions can be used to create totals. This depends on the type of the data source field providing data for the target column. The table below lists total types supported by different data source field types.

|

Data Source Field Type

|

Supported Totals

| | --- | --- | |

Boolean

|

GridColumnTotalType.Count

| |

Byte

|

GridColumnTotalType.Count

| |

Date-time

|

GridColumnTotalType.Min

GridColumnTotalType.Max

GridColumnTotalType.Count

| |

Numeric

|

All types listed in the GridColumnTotalType enumeration.

| |

String

|

GridColumnTotalType.Min

GridColumnTotalType.Max

GridColumnTotalType.Count

|

Totals, except the GridColumnTotalType.Auto type, are calculated based on summary values. When the GridColumnTotal.TotalType property is set to GridColumnTotalType.Auto, the total is calculated based on values of the corresponding data field from the underlying data source. In this case, the Measure.SummaryType property value is taken into account to calculate the total.

The following code sample demonstrates how to add totals to the Measure column.

  • The Max total displays the maximum value in the RetailPrice column.

  • The Count total displays the number of the column records.

  • C#

  • VB.NET

csharp
using DevExpress.DashboardCommon;

private void Form1_Load(object sender, EventArgs e) {
    // Creates a new Grid dashboard item. 
    GridDashboardItem grid = new GridDashboardItem();

    // ...

    // Creates a new grid measure column. 
    GridMeasureColumn colRetailPrice = new GridMeasureColumn(new Measure("RetailPrice"));

    // Creates totals of the specified total type.
    GridColumnTotal totalMax = new GridColumnTotal() { TotalType = GridColumnTotalType.Max };
    GridColumnTotal totalCount = new GridColumnTotal() { TotalType = GridColumnTotalType.Count };

    // Adds the created totals to the column's Totals collection.
    colRetailPrice.Totals.AddRange(totalMax, totalCount);

    // Adds the column to the grid's Columns collection.
    grid.Columns.Add(colRetailPrice);
}
vb
Imports DevExpress.DashboardCommon

Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
    ' Creates a new Grid dashboard item. 
    Dim grid As New GridDashboardItem()

    ' ...

    ' Creates a new grid measure column. 
    Dim colRetailPrice As New GridMeasureColumn(New Measure("RetailPrice"))

    ' Creates totals of the specified total type.
    Dim totalMax As New GridColumnTotal() With {.TotalType = GridColumnTotalType.Max}
    Dim totalCount As New GridColumnTotal() With {.TotalType = GridColumnTotalType.Count}

    ' Adds the created totals to the column's Totals collection.
    colRetailPrice.Totals.AddRange(totalMax, totalCount)

    ' Adds the column to the grid's Columns collection.
    grid.Columns.Add(colRetailPrice)
End Sub

Inheritance

Object GridColumnTotal

See Also

GridColumnTotal Members

DevExpress.DashboardCommon Namespace