- Home
- Forum
- ASP.NET MVC
- Display Sum of two columns values in another column while Cell Edit in ej grid
Display Sum of two columns values in another column while Cell Edit in ej grid
Thanks for using Syncfusion products.
We have created a sample by using column template to display the sum value and it can be downloaded from following link location.
Sample Link: http://www.syncfusion.com/downloads/support/forum/119475/ze/Sample_1194751288504676
In the above sample, we have used jQuery helper function to perform the addition operation and return into template column. When we edit a row, modified records value will be reflected in the template column. Please refer the following code example.
|
<script type="text/x-jsrender" id="columnTemplate"> {{>~Addition(First, Second)}} </script> @(Html.EJ().Grid<MvcApplication21.OrdersView>("FlatGrid") .Datasource((IEnumerable<object>)ViewBag.datasource) .EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); }) … . .Columns(col => { col.Field("EmployeeID").HeaderText("Employee ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add(); col.Field("EmployeeName").HeaderText("Employee Name").TextAlign(TextAlign.Left).Width(75).Add(); col.Field("First").HeaderText("First Value").TextAlign(TextAlign.Right).Width(75).Add(); col.Field("Second").HeaderText("Second Value").TextAlign(TextAlign.Right).Width(75).Add(); col.HeaderText("Sum Value").Template(true).TemplateID("#columnTemplate").TextAlign(TextAlign.Right).Width(110).Add(); })) <script> $.views.helpers({ Addition: function (args1, args2) { sum = args1 + args2; return sum; } }); |
Please try the above sample and get back to us if you have any concerns.
Regards,
Sellappandi R
We regret for the inconvenience caused.
We have created a sample by using grid batch edit and used the cellSave event to change the template column value based on changed value. Please refer the following example code.
|
function cellSave(args) { if (args.columnName == "First") args.cell.siblings(".e-templatecell").text(args.value + args.rowData.Second); else if (args.columnName == "Second") args.cell.siblings(".e-templatecell").text(args.value + args.rowData.First); |
Please refer the sample from the following link:
Sample link: http://www.syncfusion.com/downloads/support/forum/119475/ze/Sample856743185
Please try the above sample and let us know if it helps. If we misunderstood your query, please provide us clear information regarding your requirements. It will help us to provide the prompt solution.
Regards,
Sellappandi R
Thanks for the update.
Please get back to us if you need any further assistance we are happy to assist you.
Regards,
Sellappandi R
- 5 Replies
- 2 Participants
-
GA Ganga
- Jun 26, 2015 09:53 AM UTC
- Jul 6, 2015 12:45 PM UTC