My summaryRows is always empty (zero)
Attachment: problem_a0e1041a.zip
Thanks for contacting Syncfusion Support.
Query1: the main summary on ejGrid is always empty.
Summary Rows has not been handled in the server-side in the given code example. While using remote data, Summary Row must be handled by returning summary column and their respective datasource into the aggregate key, as shown in the below example.
|
[View] <div id="Grid" data-bind="ejGrid: {dataSource: dataSource, columns: col,showSummary: true,allowGrouping:true,summaryRows:summaryRows}"></div> <script src="~/Scripts/jsondata.min.js"></script> <script type="text/javascript"> $(function () { window.orderView = { dataSource: ej.DataManager({ url: '/Grid/DataSource', adaptor: "UrlAdaptor" }), col: [{ field: 'OrderID', headertext: 'Order ID', width: '75', textalign: ej.TextAlign.Right }, . . . ],
summaryRows: [{ title: "Sum", summaryColumns: [{ summaryType: ej.Grid.SummaryType.Sum, displayColumn: "Freight", dataMember: "Freight", format: "{0:C2}" }], showTotalSummary: true }], }; ko.applyBindings(orderView); });
|
|
[Ctrl] public partial class GridController: Controller { . . . public ActionResult DataSource(DataManager dm) {
IEnumerable DataSource = OrderRepository.GetAllRecords(); DataOperations ds = new DataOperations(); DataResult result = new DataResult(); List<string> str = new List<string>(); if (dm.Aggregates != null) { for (var i = 0; i < dm.Aggregates.Count; i++) str.Add(dm.Aggregates[i].Field); result.aggregate = ds.PerformSelect(DataSource, str); } DataSource = ds.PerformSkip(DataSource, dm.Skip); result.result = ds.PerformTake(DataSource, dm.Take); result.count = DataSource.AsQueryable().Count(); return Json(result, JsonRequestBehavior.AllowGet); } . . . |
Please refer following sample and output
Sample:
http://www.syncfusion.com/downloads/support/forum/120254/ze/MvcApplication4-1802747650
OutPut:
Query2: Can I get my Data that binding on ejGrid?
Create a Grid instance and retrieve the DataSource instance via model of Grid. We can use currentViewData from model, to retrieve the data bound currently(CurrentPage’s data) to the grid.
|
var obj = $("#Grid").ejGrid("instance") obj.model.dataSource; // instance of dataManager obj.model.currentViewData; //retreives the currentPage's data alone |
Regards,
Seeni Sakthi Kumar S.
Thanks for the update.
We are glad to know that our solution helped you achieve your requirement. Please get back to us if you need any further assistance.
Regards,
Seeni Sakthi Kumar S.
- 3 Replies
- 2 Participants
-
CS Cristiano Souza Silva
- Sep 14, 2015 10:16 PM UTC
- Sep 21, 2015 06:09 AM UTC