Is there a way to select generated aggregates on dynamic columns. I have verified that my code creating the totals is working but I am unable to utilize them in the HTML.
Component code:
// Creating the aggregates
this.operationalReportDataService.getVolumeTrend(this.choice)
.pipe(
finalize(() => this.grid.loading = false)
)
.subscribe((data: VolumeTrend) => {
this.gridView = data.gridData;
this.colSettings = data.dateColumns;
data.dateColumns.forEach(x => this.aggregates.push({ field: x.field, aggregate: 'sum' }));
});
// Generating the values
private setAverageAndTotals(data: any[]) {
// tslint:disable-next-line:max-line-length
this.totalsAndAverages = aggregateBy(data, this.aggregates);
}
HTML:
<kendo-grid-column
*ngFor="let col of this.colSettings"
field="{{col.field}}"
title="{{col.title}}"
format="{{col.format}}" width="40" [footerClass]="{'grid-footer': true}">
<ng-template
kendoGridFooterTemplate *ngIf="this.totalsAndAverages && this.lastPage"
let-column="column">Total {{column.title}}: {{totalsAndAverages["{column.title}"].sum}}
</ng-template>
</kendo-grid-column>