AggregateColumn
A column, which, when used as part of a TreeGrid, aggregates the values of this column's descendants using a configured function which defaults to sum. The aggregate value is re-calculated after any change to the data, and if you want aggregate values to be change-tracked, please set includeParentInChangeSet to true.
Default editor depends on the data field type. If it is a number, default editor is a NumberField. Otherwise Default editor is a TextField.
const grid = new TreeGrid({
// Custom aggregation handler.
// For test purposes, this just does "sum"
myAggregator(...values) {
let result = 0;
for (let i = 0, { length } = values; i < length; i++) {
result += parseInt(args[i], 10);
}
return result;
},
columns : [
{ field : 'name', text : 'Name' },
// Will sum the ages of leaf nodes. This is the default.
{ type : 'aggregate', field : 'age', text : 'Age', renderer : ({ value }) => `<b>${value}<b>` },
// Will use AggregateColumn's built-in avg of scores of leaf nodes
{ type : 'aggregate', field : 'score', text : 'Score', function : 'avg' },
// Will use the grid's myAggregator function
{ type : 'aggregate', field : 'revenue', text : 'Revenue', function : 'up.myAggregator' },
]
});
Useful configs
| Config | Description |
|---|---|
| function | Aggregation function (sum, avg, or custom) |
| includeParentInChangeSet | Track aggregate changes in modifications |
| enableAggregation | Enable/disable aggregation |
See also
- NumberColumn - Parent column type
- TreeGrid - Tree grid for hierarchical data
Configs
Configs are options you supply in a configuration object when creating an instance of this class-
Set to
falseto disable aggregates being calculated.Has a corresponding runtime enableAggregation property.
-
Set to
trueto include filtered out records in the aggregation.Has a corresponding runtime includeFilteredOutRecords property.
-
Set to
trueto include changes to parent (aggregate) rows in the store's modification tracking.Has a corresponding runtime includeParentInChangeSet property.
Properties
Properties are getters/setters or publicly accessible variables on this class-
Identifies an object as an instance of AggregateColumn class, or subclass thereof.
-
Set to
falseto disable aggregates being calculated.Has a corresponding enableAggregation config.
-
Set to
trueto include filtered out records in the aggregation.Has a corresponding includeFilteredOutRecords config.
-
Set to
trueto include changes to parent (aggregate) rows in the store's modification tracking.Has a corresponding includeParentInChangeSet config.
-
Identifies an object as an instance of AggregateColumn class, or subclass thereof.