HI Sathyanarayanamoorthy,
Thanks for your reply.
I have a summary that counts the total of a specific column and I want to update that summary immediately with every batch update before it gets sent back to the server, and it seems there is no straightforward way to achieve this using the standard summary column and I would be happy if you could give me a hint on how to use the getBatchChanges to achieve this.
Kind Regards,
|
<script type="text/javascript">
$(function () {
var data = window.gridData;
$("#Grid").ejGrid({
…...
summaryRows: [
{ title: "Sum", summaryColumns: [{ summaryType: ej.Grid.SummaryType.Sum, displayColumn: "Freight", dataMember: "Freight", format: "{0:C2}" }] }
],
columns: [
{ field: "OrderID", isPrimaryKey: true, headerText: "Order ID"},
…...
{ field: "Freight" },
],
beforeBatchDelete: "del"
});
});
</script>
<script type="text/javascript">
function del(args) {
var format;
var removedvalue = args.rowData.Freight;// getting the old value
for (var i = 0; i < this.model.summaryRows.length; i++)
for (var j = 0; j < this.model.summaryRows[i].summaryColumns.length; j++) {
if (this.model.summaryRows[i].summaryColumns[j].dataMember == "Freight" && this.model.summaryRows[i].summaryColumns[j].summaryType == "sum"){
format = !ej.isNullOrUndefined(this.model.summaryRows[i].summaryColumns[j].format) ? this.model.summaryRows[i].summaryColumns[j].format : "{0:N}";//getting the format of the summaryColumn
j = i;// finding the summaryRow to be modified
break;
}
}
var summary = ($(".e-gridSummaryRows:eq(" + j + ")").find("td.e-summaryrow")[this.getColumnIndexByField("Freight")].innerHTML).replace(/[$,]/g, "")// getting the summaryValue of the corresponding summaryRow
var summaryval = (parseFloat(summary) - removedvalue);
summaryval = this.formatting(format,summaryval);//get the formatted value of the summary Value
$(".e-gridSummaryRows:eq(" + j + ")").find("td.e-summaryrow")[args.rowIndex].innerHTML = summaryval;//assigning the innerHTML of the summaryrow with updated value
}
</script> |