I need to display the first value in a group in the group row so first i tried to display a constant using aggregation, I have this column def
name: 'Stack',
displayName: 'Stack',
grouping: { groupPriority: 1 },
treeAggregation: { type:this.uiGridGroupingConstants.aggregation.CUSTOM },
customTreeAggregationFn: this.aggregateService.accumulateNumValue,
customTreeAggregationFinalizerFn: this.aggregateService.medianFinalize,
visible: true,
minWidth: '70',
Grouping is done using another column which is hidden, I tried to using custom aggregationTree with finalize method doing only
if ( angular.isUndefined(aggregation.stats.accumulator) ){
aggregation.stats.accumulator = [];
}
this piece of code throws an error
TypeError: Cannot read property 'accumulator' of undefined
at GridColumn.AggregationService.medianFinalize [as customTreeAggregationFinalizerFn] (http://localhost:8080/bundle.js:135388:55)
at Object.finaliseAggregation (http://localhost:8080/bundle.js:74042:28)
at http://localhost:8080/bundle.js:74073:20
at Array.forEach (native)
at Object.finaliseAggregations (http://localhost:8080/bundle.js:74072:36)
at createNode (http://localhost:8080/bundle.js:73647:24)
at Array.forEach (native)
at Object.createTree (http://localhost:8080/bundle.js:73679:25)
at Grid.treeRows (http://localhost:8080/bundle.js:73544:39)
at startProcessor (http://localhost:8080/bundle.js:52026:34)
What I do not understand how this throws an error, I removed the 3 lines of code and the error no longer exists but i clearly need to access the tats.accumulator as this is the array where i push my data in the aggregation function.