groupItems[]

Specifies items of the group summary.

Type: Array
Default Value: undefined

The group summary provides a synopsis of a group of data. Groups of data are formed in the process of grouping. The group summary contains several items. Each item displays a value that is a product of applying an aggregate function to a group of data.

To specify the items of the group summary, declare an array of objects, each of which contains at least two fields: column and summaryType. The column field specifies the identifier of the column that provides data for an aggregate function. The summaryType specifies the aggregate function to be applied. The following code snippet shows how to declare two summary items.

JavaScript
$("#gridContainer").dxDataGrid({
    // ...
    summary: {
        groupItems: [{
            column: 'Age',
            summaryType: 'avg'
        }, {
            column: 'LastName',
            summaryType: 'count'
        }]
    }
});

A group summary item may be located either in the group row or the group footer. By default, the group row holds all summary items. To locate a summary item in the group footer, set the showInGroupFooter option of this item to true.

View Demo

column

Specifies the column that provides data for a group summary item.

Type: String
Default Value: undefined

To provide data for a group summary item, assign the name, data field or caption of a column to this option. This item will be displayed in each group row when grouping is applied. If you require to place the group summary item in the group footer, set the showInGroupFooter option to true for this item.

customizeText

Customizes the text to be displayed in the summary item.

Type: function(itemInfo)
Function parameters:
itemInfo: Object

Data of the summary item.

Object structure:

Summary item value as it was calculated.

valueText: String

Summary item value with applied format and precision.

Return Value: String

Text to be displayed in the summary item.

This option accepts a function that must return the text to be displayed in the summary item. When you implement this function, you can access the summary item value using the fields of object passed to the function as its argument.

displayFormat

Specifies a pattern for the summary item text.

Type: String
Default Value: undefined

When implementing the pattern, you can access the summary item value with applied format and precision using position marker 0. If the summary item is placed in any other column rather than its parent one, you can also access the caption of the parent column using position marker 1. Place each of these position markers within curly brackets.

If your scenario requires more complex text customizations, utilize the customizeText option.

name

Specifies the identifier of a summary item.

Type: String
Default Value: undefined

Specify this option if you need to refer to a summary item in your code afterwards, e.g., inside the calculateCustomSummary function.

precision

Specifies a precision for the summary item value of a numeric format.

Type: Number
Default Value: undefined

This option accepts a number indicating how many digits after the decimal point a summary item value must contain. This option applies only when the summary item value has a numeric format.

showInColumn

Specifies the column that must hold the summary item when this item is displayed in the group footer.

Type: String
Default Value: undefined

By default, a summary item in the group footer is held by the column that provides data for this item. If you need to place it in another column, assign the name, data field or caption of this column to the showInColumn option.

showInGroupFooter

Specifies whether or not a summary item must be displayed in the group footer.

Type: Boolean
Default Value: false

By default, summary items are displayed as a part of a group row. If you need a summary item to be displayed in the group footer, assign true to the showInGroupFooter option of this item. This summary item will be located in the column that provides data for it. If you want another column to hold the summary item, specify the showInColumn option of this item.

summaryType

Specifies how to aggregate data for a summary item.

Type: String
Default Value: undefined
Accepted Values: "sum" | "min" | "max" | "avg" | "count" | "custom"

A summary item displays a value that is a product of applying an aggregate function to a group of data from a specific column. This aggregate function is defined by the summary type. The following list gives an overview of available summary types.

  • "sum"
    Sums up all values in a column within the group.
  • "min"
    Calculates the minimum value in a column within the group.
  • "max"
    Calculates the maximum value in a column within the group.
  • "avg"
    Calculates the average of all values in a column within the group.
  • "count"
    Calculates the number of items in a column within the group.
  • "custom"
    Allows you to specify a custom aggregate function using the calculateCustomSummary option.

valueFormat

Specifies a format for the summary item value.

Type: String
Default Value: undefined
Accepted Values: "currency" | "fixedPoint" | "percent" | "decimal" | "exponential" | "largeNumber" | "thousands" | "millions" | "billions" | "trillions" | "longDate" | "longTime" | "monthAndDay" | "monthAndYear" | "quarterAndYear" | "shortDate" | "shortTime" | "millisecond" | "day" | "month" | "quarter" | "year"

Additionally, you can set a precision for the summary item value if it has a numeric format. For this purpose, use the precision option.

NOTE: If you set this option to 'currency', cell values will be formatted according to the settings specified for the current culture in the globalize library. To provide a custom 'currency' format, use the customizeText option instead.