Vue Data GridAggregation

Enterprise

Apply custom or provided functions to values to calculate group values in the grid.

Enabling Aggregation Copy

Aggregations can be enabled in the grid by setting the aggFunc column definition value to one of: sum, min, max, count, avg, first, or last.

The following configuration demonstrates how to enable aggregation on a column:

<ag-grid-vue
    :columnDefs="columnDefs"
    /* other grid options ... */>
</ag-grid-vue>

this.columnDefs = [
    { field: 'gold', aggFunc: 'sum' },
    { field: 'silver', aggFunc: 'max' },
    { field: 'bronze', aggFunc: 'avg' },
    // ... other column definitions
];

API Reference Copy

Aggregations can be configured using the following column properties:

Name of function to use for aggregation. In-built options are: sum, min, max, count, avg, first, last. Also accepts a custom aggregation name or an aggregation function.
Same as aggFunc, except only applied when creating a new column. Not applied when updating column definitions.
enableValueCopy
boolean
default: false
Set to true if you want to be able to aggregate by this column via the GUI. This will not block the API or properties being used to achieve aggregation.
allowedAggFuncsCopy
string[]
Aggregation functions allowed on this column e.g. ['sum', 'avg']. If missing, all installed functions are allowed. This will only restrict what the GUI allows a user to select, it does not impact when you set a function via the API.
defaultAggFuncCopy
string
default: 'sum'
The name of the aggregation function to use for this column when it is enabled via the GUI. Note that this does not immediately apply the aggregation function like aggFunc

Aggregation functions can be registered with the grid using the following grid options:

aggFuncsCopy
{ [key: string]: IAggFunc }
A map of 'function name' to 'function' for custom aggregation functions.
groupTotalRowCopy
'top' | 'bottom' | UseGroupTotalRow
When provided, an extra row group total row will be inserted into row groups at the specified position, to display when the group is expanded. This row will contain the aggregate values for the group. If a callback function is provided, it can be used to selectively determine which groups will have a total row added.
grandTotalRowCopy
'top' | 'bottom'
When provided, an extra grand total row will be inserted into the grid at the specified position. This row displays the aggregate totals of all rows in the grid.
suppressAggFuncInHeaderCopy
boolean
default: false
When true, column headers won't include the aggFunc name, e.g. 'sum(Bank Balance)' will just be 'Bank Balance'.
aggregateOnlyChangedColumnsCopy
boolean
default: false
When using change detection, only the updated column will be re-aggregated.
suppressAggFilteredOnlyCopy
boolean
default: false
Set to true so that aggregations are not impacted by filtering.
groupAggFilteringCopy
boolean | IsRowFilterable
default: false
Set to determine whether filters should be applied on aggregated group values.
groupSuppressBlankHeaderCopy
boolean
default: false
If true, and showing footer, aggregate data will always be displayed at both the header and footer levels. This stops the possibly undesirable behaviour of the header details 'jumping' to the footer on expand.
suppressStickyTotalRowCopy
boolean | 'grand' | 'group'
Suppress the sticky behaviour of the total rows, can be suppressed individually by passing 'grand' or 'group'.
alwaysAggregateAtRootLevelCopy
boolean
default: false
When using aggregations, the grid will always calculate the root level aggregation value.
getGroupRowAggCopy
Function
Callback to use when you need access to more then the current column for aggregation.

After the grid is initialised aggregations can be applied / retrieved / removed via the api with the following methods:

getValueColumnsCopy
Function
Get a list of the existing value columns.
addValueColumnsCopy
Function
Add the given list of columns to the existing set of value columns.
removeValueColumnsCopy
Function
Remove the given list of columns from the existing set of value columns.
setValueColumnsCopy
Function
Set the value columns to the provided list of columns.
setColumnAggFuncCopy
Function
Sets the agg function for a column. aggFunc can be one of the built-in aggregations or a custom aggregation by name or direct function.
addAggFuncsCopy
Function
Add aggregations function with the specified keys.
clearAggFuncsCopy
Function
Clears all aggregation functions (including those provided by the grid).

Next Up Copy

Continue to the next section to learn how to Configure Columns.