- Home
- Forum
- ASP.NET Web Forms
- Updating Summary Row with Batch Edit
Updating Summary Row with Batch Edit
We have created a sample to update the summary row on editing and saving a cell in batch editing, which can be downloaded from the below location.
Sample Link: http://www.syncfusion.com/downloads/support/forum/121227/ze/Sample2024805759
In the above sample, we have pdated the summary row using the CellSave clientside event. Please refer to the below code example.
|
<ej:Grid ID="OrdersGrid" runat="server" AllowPaging="True" > <ClientSideEvents CellSave="cellSave" /> . . . <EditSettings AllowEditing="True" AllowAdding="True" AllowDeleting="True"EditMode="Batch"></EditSettings> </ej:Grid> <script type="text/javascript"> function cellSave(args) { if (args.columnName == "Freight") { var newvalue = args.value;// getting the new value var oldvalue = args.rowData.Freight;// getting the old value var extra = newvalue - oldvalue;//getting the difference in value var summary = ($("td.e-summaryrow")[args.cell.index()].innerHTML).replace(/[$,]/g, "") var summaryval = (parseFloat(summary) + extra).toFixed(2); summaryval = addCommas(summaryval);//add commas to the obtained value $("td.e-summaryrow")[args.cell.index()].innerHTML = "$" + summaryval;//assigning the innerHTML of the summaryrow with updated value } }
|
Regards,
Ragavee U S.
We have modified the solution based on your requirement and the sample can be downloaded from the below location.
Sample Link: http://www.syncfusion.com/downloads/support/forum/121227/ze/Sample_modified1674156755
In the above sample, we have obtained the corresponding summaryRow index to be modified using Grid model SummaryRows and thus updated that summaryRow. Please refer to the below code example.
|
<script type="text/javascript"> function cellSave(args) { if (args.columnName == "Freight") { var newvalue = args.value;// getting the new value var oldvalue = args.rowData.Freight;// getting the old value var extra = newvalue - oldvalue;//getting the difference in 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"){ j = i;// finding the summaryRow to be modified break; } } var summary = ($(".e-gridSummaryRows:eq(" + j + ")").find("td.e-summaryrow")[args.cell.index()].innerHTML).replace(/[$,]/g, "")// getting the summaryValue of the corresponding summaryRow var summaryval = (parseFloat(summary) + extra).toFixed(2); summaryval = addCommas(summaryval);//add commas to the obtained value $(".e-gridSummaryRows:eq(" + j + ")").find("td.e-summaryrow")[args.cell.index()].innerHTML = "$" + summaryval;//assigning the innerHTML of the summaryrow with updated value } } |
Regards,
Ragavee U S.
Thanks for your update.
We are happy that your requirement is achieved.
Regards,
Ragavee U S.
- 5 Replies
- 2 Participants
-
JA James
- Nov 19, 2015 09:57 PM UTC
- Nov 25, 2015 06:09 AM UTC