We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Display Sum of two columns values in another column while Cell Edit in ej grid

if (args.columnName == "NoofFlats" )
                            var N1 = parseInt(args.value);                          
                        if (args.columnName == "NoofShops")
                            var N12= parseInt(args.value);                            

5 Replies

SR Sellappandi Ramu Syncfusion Team June 29, 2015 11:46 AM UTC

Hi Ganga,

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)}}




        .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();




        Addition: function (args1, args2) {

            sum = args1 + args2;

            return sum;



Please try the above sample and get back to us if you have any concerns.

Sellappandi R

GA Ganga July 1, 2015 09:26 AM UTC

The above Code,only working in Grid Load not in cell edit or cell save.
i want to add the columns while edit the cell not loading.

SR Sellappandi Ramu Syncfusion Team July 2, 2015 01:12 PM UTC

Hi Ganga,

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.

Sellappandi R

GA Ganga July 3, 2015 06:57 AM UTC

Thanks,Its Working Fine..

SR Sellappandi Ramu Syncfusion Team July 6, 2015 12:45 PM UTC

Hi Ganga,

Thanks for the update.

Please get back to us if you need any further assistance we are happy to assist you.

Sellappandi R

Live Chat Icon For mobile
Up arrow icon