[index.js]
var grid = new ej.grids.Grid({
dataSource: localdata,
allowPaging: true,
pageSettings: { pageCount: 5 },
editSettings:{allowEditing:true, allowDeleting:true, allowAdding:true, mode:"Batch"},
toolbar:["Add","Edit","Delete","Update","Cancel"],
cellSave:function(args){
var editedRowIndex = parseInt(ej.base.closest(args.cell,".e-row").getAttribute("aria-rowindex"),10);
if(args.columnName === "Quantity" || args.columnName === "Multiplier" || args.columnName === "Value") {
var quantity = args.columnName === "Quantity" ? args.value : args.rowData.Quantity;
var value = args.columnName === "Value" ? args.value : args.rowData.Value;
var multiplier = args.columnName === "Multiplier" ? args.value : args.rowData.Multiplier;
var amount = (quantity * multiplier * value);
if(!isNaN(amount)){
args.rowData.amount = amount;
this.editModule.updateCell(editedRowIndex, "Amount", amount);
}
}
},
columns: [
. . . .
],
aggregates: [{
columns: [{
type: 'Sum',
field: 'Amount',
format: 'C2',
footerTemplate: 'Total: ${Sum}'
}]
}]
});
grid.appendTo('#Grid'); |