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,
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,