Posted 18 May 2021, 8:17 pm EST
I am using the below script to update the “Column3” data based on “Column1” and “Column2”. If I do not use the “setCellData” then the “Column3” data doesn’t get its grand total in the bottom row and also the export will not have any data populated for it.
So to resolve the issue I used “setCellData” and the two issues are fixed. But now I am not able to edit “Column1” or “Column2” properly as these columns are getting flickered. You can check the behavior at
https://unnati-khanorkar.outsystemscloud.com/DataGridIssue/Entry1.aspx
Adding the code snippet used -
//Add Grand total row at the end
var addSumRow = function(gridId){
var gObj = GridOS.ComponentUtils.getGridObjectById(gridId);
var grid = gObj.grid;
grid.columnFooters.rows.push(new wijmo.grid.GroupRow());
grid.bottomLeftCells.setCellData(0, 0, ‘Total’);
};
// custom cell calculation var calculateGridColumn = function(gridId){ var gObj = GridOS.ComponentUtils.getGridObjectById(gridId); var grid = gObj.grid; grid.formatItem.removeAllHandlers();
// wijmo.grid.xlsx.FlexGridXlsxConverter.save(grid,{formatItem:exportFormatItem},“Grid.xlsx”);
grid.formatItem.addHandler(function (s, e) {
//
// cells and column footer panels only
if (e.panel == s.cells) {
//
// get row, column, and data item (or group description)
var r = s.rows[e.row];
var c = s.columns[e.col];
var item = s.rows[e.row].dataItem;
var group = r instanceof wijmo.grid.GroupRow ? item : null;
// assume value is not negative
var negative = false;
//
// calculate
if (c.binding == ‘Column3’) {
var column3Data = group ? group.getAggregate(‘Sum’, ‘Column1’) + group.getAggregate(‘Sum’, ‘Column2’)
: item.Column1 + item.Column2;
var column3Data = isNaN(column3Data)?0:column3Data;
e.cell.textContent = wijmo.Globalize.format(column3Data, c.format);
e.cell.innerHTML = wijmo.Globalize.format(column3Data, c.format);
e.panel.setCellData(e.row,e.col,wijmo.Globalize.format(column3Data, c.format)); // s.invalidate(); // negative = column3Data < 0; } // // update 'negative' class on cell wijmo.toggleClass(e.cell, 'negative', negative); } });
grid.invalidate();
};
Please let me know how can I fix the issue as I am not able to edit the column1 and column 2 data.