Posted 7 October 2018, 5:53 pm EST
Hi Sharad,
I have to modify some special GrandTotal values, and then I can export to Excel file using this grid. However, if I modified the GrandTotal values by cell.innerHTML, the values exported Excel file are different from displayed in grid.
So I finished my requirement by calling method setCellData() in formatItem.addHandler(). Finally, the result is the formatItem() being called in an infinite loop.
Is there any advice to avoid such a problem?
the code I modify some special Grand Total values:
let specialMea = ['spe1', 'spe2', 'spe3'];
let mea = [
{type: 'spe0', name: 'downloads'},
{type: 'spe1', name: 'sales'}
];
gridPivot.formatItem.addHandler(function(s, e) {
if (e.panel === s.cells && wijmo.hasClass(e.cell, 'wj-aggregate')) {
let dataValue;
if(e.row === gridPivot.rows.length - 1) {
dataValue = ' row total';
} else {
dataValue = 'column total';
}
for (let i = 0; i < mea.length; i++) {
if (specialMea.includes(mea[i].type)) {
if (s.columns[e.col].binding + ':0;'.includes(mea[i].name + ':0;')) {
// e.panel.setCellData(e.row, e.col, dataValue, false);
e.cell.innerHTML = wijmo.Globalize.format(dataValue, s.columns[e.col].format);
}
}
}
}
}