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.
Unfortunately, activation email could not send to your email. Please try again.

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

Thread ID:

Created:

Updated:

Platform:

Replies:

119475 Jun 26,2015 05:53 AM Jul 6,2015 08:45 AM ASP.NET MVC 5
loading
Tags: Grid
Ganga
Asked On June 26, 2015 05:53 AM




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

Sellappandi Ramu [Syncfusion]
Replied On June 29, 2015 07:46 AM

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

</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;

        }

    });
</script>


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

Regards,
Sellappandi R

Ganga
Replied On July 1, 2015 05:26 AM



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.

Sellappandi Ramu [Syncfusion]
Replied On July 2, 2015 09:12 AM

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.

Regards,
Sellappandi R

Ganga
Replied On July 3, 2015 02:57 AM

Thanks,Its Working Fine..

Sellappandi Ramu [Syncfusion]
Replied On July 6, 2015 08:45 AM

Hi Ganga,

Thanks for the update.

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

Regards,
Sellappandi R


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;