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.

Custom summary on Grouped rows

Thread ID:

Created:

Updated:

Platform:

Replies:

127108 Oct 26,2016 08:48 AM Oct 28,2016 10:27 AM JavaScript 3
loading
Tags: ejGrid
Andrea Perazzolo
Asked On October 26, 2016 08:48 AM

Hi,
I Have an OData V4 Paged bound grid.
I Group for a column and want to show some totals on the Summary rows of group.
My first problem is that the normal sum is calculated on the grid page data, and if the group is spread across pages I have not the real values on the totals.
I tried with the custom Summary, trying to call an ODATA function to calculate the correct data o the server,, but I don't know how to retrieve, in the custom javascript function the current value of the group where the summary row is calculated.
There is any solution for my problem?

      Thanks in advance

     Andrea Perazzolo

Mani Sankar Durai [Syncfusion]
Replied On October 27, 2016 02:22 AM

Hi Andrea, 
 
 
Thanks for contacting Syncfusion support. 
 
 
While using ODataV4 adaptors we can get only current page data, so we can’t get aggregates for entire grouped records which are in next page too. Suppose if you want to show aggregate for entire dataSource while using ODataV4Adaptor then we need to send multiple post to server to get the entire data and then send the aggregate through adaptor, so this is not feasible and currently we don’t have support for this by default. Hence we suggest you to use UrlAdaptor instead of ODataV4Adaptor to display the aggregate for whole dataSource. 
 
Please refer the documentation link of about how to use aggregate in UrlAdaptor. 
 
 
 
Regards, 
Manisankar Durai. 


Andrea Perazzolo
Replied On October 27, 2016 02:36 AM

Thanks for the reply.
I'll ask if there is a way to access the current grouped data in the function that is used to calculate the summary value in the custom summary.
It will be sufficient for me for calling a server function that calculate the whole total for the group.

      Thanks in advance

     Andrea Perazzolo

Seeni Sakthi Kumar Seeni Raj [Syncfusion]
Replied On October 28, 2016 10:27 AM

Hi Andrea, 

We cannot achieve your requirement using the Odata service. But we can achieve it using the UrlAdaptor. Refer to the following code example. 

namespace MvcApplication66.Controllers 
{ 
    public class HomeController : Controller 
    { 
        public ActionResult DataSource(Syncfusion.JavaScript.DataManager dm) 
        { 
 
            IEnumerable datasource = new NorthwindDataContext().EmployeeViews.ToList(); 
            DataResult result = new DataResult(); 
            DataOperations operation = new DataOperations(); 
            . . .. . .  
            List<string> str1 = new List<string>(); 
            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 = operation.PerformSelect(datasource, str); 
            } 
            if (dm.Group != null) { 
                for (var i = 0; i < dm.Group.Count; i++) 
                    str1.Add(dm.Group[i]); 
                result.groupDs = operation.PerformSelect(DataSource, str1); 
                if (dm.Aggregates != null) 
                { 
                    for (var i = 0; i < dm.Aggregates.Count; i++) {  
                        if(str1.IndexOf(dm.Aggregates[i].Field)==-1) 
                            str1.Add(dm.Aggregates[i].Field); 
                    } 
                    result.groupDs = operation.PerformSelect(DataSource, str1); 
                } 
            } 
            result.count = count; 
            result.result = datasource; 
            return Json(result, JsonRequestBehavior.AllowGet); 
        } 
    } 
} 
 
        public class DataResult 
        { 
            public IEnumerable result { get; set; } 
            public int count { get; set; } 
            public IEnumerable aggregate { get; set; } 
            public IEnumerable groupDs { get; set; } 
        } 
 
<div id="Grid"></div> 
<script type="text/javascript"> 
    $(function () { 
        $("#Grid").ejGrid({ 
            dataSource: ej.DataManager({ 
                url: "/Home/DataSource", 
                adaptor: new ej.UrlAdaptor() 
            }), 
            summaryRows: [ 
                    { title: "Sum", summaryColumns: [{ summaryType: ej.Grid.SummaryType.Sum, displayColumn: "Freight", dataMember: "Freight", format: "{0:C2}" }] }, 
                                 . .  
            ], 
        }); 
    }); 
</script> 

The above code example handles the data for Total summary as well as the Group summary of the Grid. 

Regards, 
Seeni Sakthi Kumar S.  


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.

;