Grid Summary Batch DataSource Update UrlAdaptor

Hi there,

I have been trying to use Summary and Summary Template sample shown in mvc.syncfusion page.  However it seems the sample has entire data loaded up at once.  I have couple pages which have child grid which gets refreshed based on parent record in parent grid.  I want the child grid to have summary (sum, average etc).  I can't seems to get my get around to get this working if the datasource is retrieved by URL adaptor type.

.Datasource(ds => ds.URL("BatchDataSource")
                            .BatchURL("BatchUpdate").Adaptor(AdaptorType.UrlAdaptor))

If you could provide a working sample that would be greatly appreciated.

Regards
Prasanth

1 Reply

MS Mani Sankar Durai Syncfusion Team November 14, 2017 11:06 AM UTC

Hi Prasanthan, 

Thanks for contacting Syncfusion support. 

We have analyzed your query and found that you want to perform summary for the child grid while using URLAdaptor.  To show the summary for the columns in grid while using URLAdaptor we have perform Aggregates in server side. 
Based on your requirement we have prepared a sample that can be downloaded from the below link 

Please refer the below code example 
@(Html.EJ().Grid<object>("HierarchyGrid") 
        .Datasource((IEnumerable<object>)ViewBag.datasource) 
      .Columns(col => 
        { 
... 
        }) 
                 .ChildGrid(child => 
                 { 
                     child.Datasource(ds => ds.URL("/Grid/UrlDataSource").Adaptor(AdaptorType.UrlAdaptor)) 
                        .QueryString("EmployeeID") 
                         .ShowSummary() 
 
        .SummaryRow(row => 
        { 
            row.Title("Sum").SummaryColumns(col => { col.SummaryType(SummaryType.Sum).Format("{0:C}").DisplayColumn("Freight").DataMember("Freight").Add(); }).Add(); 
            row.Title("Average").SummaryColumns(col => { col.SummaryType(SummaryType.Average).Format("{0:C}").DisplayColumn("Freight").DataMember("Freight").Add(); }).Add(); 
        }) 
... 
                 }) 
 
) 
 
[GriFeatures.cs] 
public ActionResult UrlDataSource(DataManager dm) 
        { 
 
            IEnumerable DataSource = new NorthwindDataContext().OrdersViews.ToList(); 
            DataOperations ds = new DataOperations(); 
            List<string> str = new List<string>(); 
... 
            if (dm.Where != null && dm.Where.Count > 0) //Filtering 
            { 
                DataSource = ds.PerformWhereFilter(DataSource, dm.Where, dm.Where[0].Operator); 
            } 
            if (dm.Aggregates != null) 
            { 
                for (var i = 0; i < dm.Aggregates.Count; i++) 
                    str.Add(dm.Aggregates[i].Field); 
            } 
            IEnumerable aggregate = ds.PerformSelect(DataSource, str); 
            var count = DataSource.Cast<OrdersView>().Count(); 
            if(dm.Skip != 0 ) 
                DataSource = ds.PerformSkip(DataSource, dm.Skip); 
            if (dm.Take != 0) 
                DataSource = ds.PerformTake(DataSource, dm.Take); 
 
            return Json(new { result = DataSource, count = count, aggregate = aggregate });  //return that result with aggregate details also. 
        } 
 


We have also already documented a documentation of how to handle Aggregation in server side and that can be available from the below link 

Please let us know if you need further assistance. 

Regards, 
Manisankar Durai. 


Loader.
Up arrow icon