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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Asp.net mvc-EjGrid

Thread ID:

Created:

Updated:

Platform:

Replies:

118335 Feb 26,2015 10:21 AM UTC Mar 30,2015 02:13 PM UTC ASP.NET MVC 6
loading
Tags: Grid
Ganga
Asked On February 26, 2015 10:21 AM UTC


how to sum the particular column values in grid

Sellappandi Ramu [Syncfusion]
Replied On February 27, 2015 06:29 AM UTC

Hi Ganga,

Thanks for your interest in Syncfusion products.

We have analyzed your requirement for “Sum the particular column values in grid” and created a sample. The sample can be downloaded from following link:

Sample: http://www.syncfusion.com/downloads/support/directtrac/118335/MvcGrid685789389.zip

For your information, Grid control has the default property of ShowSummary. Using ShowSummary property to aggregate a particular column. Please refer the following code snippet.

@(Html.EJ().Grid<MvcGrid.OrdersView>("FlatGrid")

        .Datasource((IEnumerable<object>)ViewBag.datasource)

        .AllowScrolling()

        .ShowSummary()

        .SummaryRow(row =>

        {

            row.Title("Sum").SummaryColumns(col =>

            {

col.SummaryType(SummaryType.Sum).Format("{0:C}").DisplayColumn("Freight").DataMember("Freight").Add();

            }).Add();

        })

        .Columns(col =>

        {

                                ….           

        }))

For your reference we have provided the online link below.

Online sample link: http://mvc.syncfusion.com/demos/web/grid/summary

Online help documentation: http://help.syncfusion.com/ug/js/documents/summary1.htm

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

Regards,

Sellappandi R

Ganga
Replied On February 27, 2015 01:13 PM UTC

Sorry .I can't get this correctly..Is there any other way to show that total value in a text box ???

Ganga
Replied On February 28, 2015 06:36 AM UTC

Thankz For Sending.
its appending my values. for example 35,34=3534..
How to solve this

Sellappandi Ramu [Syncfusion]
Replied On March 2, 2015 02:25 PM UTC

Hi Ganga,

Thanks for your interest in Syncfusion products.

Query #1: Its appending my values, How to solve this?

We have analyzed your reported issue at our end and we would like you to share the following information to us to sort out the cause of the issue.

1. Please share your data source to us.

2. Could you please replicate the issue in the attached sample or kindly provide the issue reproducing sample?

We are unable to reproduce the issue while testing the sample by using string type of value to column, even summary row displayed the sum values. Because using showSummary property, we are converted string  value to number format on before aggregate.

Query #2: Is there any other way to show that total value in a text box ???

We have created the sample based on your requirement and the sample can be downloaded from following link:

Sample Link: http://www.syncfusion.com/downloads/support/directtrac/118335/MvcGrid1151188107.zip

In the provided sample we have used create event to hide the summary row and display the sum value to text box. Please refer the following code snippet.

@(Html.EJ().Grid<MvcGrid.OrdersView>("FlatGrid")

        .Datasource((IEnumerable<object>)ViewBag.datasource)

        .AllowScrolling()

        .ShowSummary()

        .EditSettings(e=>e.AllowEditing())

        .SummaryRow(row =>

        {

            row.Title("Sum").SummaryColumns(col =>

            {

                col.SummaryType(SummaryType.Sum).DisplayColumn("ShipPostalCode").DataMember("ShipPostalCode").Add();

            }).Add();

        })

        .Columns(col =>

        {

                ….

        }).ClientSideEvents(e => e.Create("create").ActionComplete("create")))

<div>

    <table><tbody><tr><td>Sum of Frieght:</td><td>@Html.EJ().NumericTextbox("numeric")</td></tr></tbody></table>

</div>

<script>

    function create(args) {

        var gridObj = $("#FlatGrid").ejGrid("instance");

        gridObj.element.find(".e-gridsummary").addClass("e-hide");

        $("#numeric").val($(gridObj.element.find(".e-gridsummary .e-summaryrow")[gridObj.getColumnIndexByField("ShipPostalCode")]).html());

    }

</script>

Please try the above sample and get back to us with the mentioned details.

Regards,

Sellappandi R

Ganga
Replied On March 28, 2015 05:09 AM UTC

Thank u sir.It's Working Fine.

Sellappandi Ramu [Syncfusion]
Replied On March 30, 2015 02:13 PM UTC

Hi Ganga,

Thanks for the update.

Please get back to us if you need any further assistance.

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.

Warning Icon 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.Close Icon

;