<ejs-pivotview #pivotview id='PivotView' [dataSourceSettings]=dataSourceSettings width='100%' height='300'
(enginePopulated)='enginePopulated($event)' showFieldList='true' >
</ejs-pivotview>
public columnGrandTotalIndex;
public rowGrandTotalIndex;
queryCell(args: any): void {
(this.pivotGridObj.renderModule as any).rowCellBoundEvent(args);
if (this.pivotGridObj.pivotValues[0]) {
for (var i = 0; i < this.pivotGridObj.pivotValues[0].length; i++) {
if (this.columnGrandTotalIndex == undefined && this.pivotGridObj.pivotValues[0][i] && (((this.pivotGridObj.pivotValues[0][i] as IAxisSet).type as String === "grand sum") || ((this.pivotGridObj.pivotValues[0][i] as IAxisSet).valueSort && ((this.pivotGridObj.pivotValues[0][i] as IAxisSet).valueSort.levelName as String).includes("Grand Total")))) {
this.columnGrandTotalIndex = i;
}
}
for (var i = 0; i < this.pivotGridObj.pivotValues.length; i++) {
if (this.rowGrandTotalIndex == undefined && this.pivotGridObj.pivotValues[i][0] && (this.pivotGridObj.pivotValues[i][0] as IAxisSet).type as String === "grand sum") {
this.rowGrandTotalIndex = i;
}
}
if (args.cell.innerText != "Grand Total") {
// To customize column grand totals
if (args.data[args.cell.getAttribute("aria-colindex")].colIndex >= this.columnGrandTotalIndex) {
args.cell.innerText = "0";
}
// To customize row grand totals
if (args.data[args.cell.getAttribute("aria-colindex")].rowIndex >= this.rowGrandTotalIndex) {
args.cell.innerText = "1";
}
}
}
this.columnGrandTotalIndex = undefined;
this.rowGrandTotalIndex = undefined;
}
enginePopulated(args: any): void {
this.pivotGridObj.grid.queryCellInfo = this.queryCell.bind(this);
}
|