This is a migrated thread and some comments may be shown as answers.

Group aggregates - how to react to grouping changes

2 Answers 198 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 16 Jun 2015, 02:21 PM

Hi,

 After a lot of searching I found out how to get group-level and grand-total aggregates working.  

 However, now that is in place, I find that changing the grouping via the GUI blows up.  

I guess this makes sense since the aggregation is set as a static object, but this must be a common requirement surely?  I want to have group level aggregates and the grand total continue to work even if the user wants different grouping.

 I've created a JSFiddle to focus any help people can offer.

I suspect this may involve my catching a grid event but I welcome any suggestion.  I can reference an object as the datasource group attribute.

var grouping = {
    field: "deal.dealStatus",
    aggregates: [{
        field: "valueUSD",
        aggregate: "sum"
    }]
};
 
 
 
    dealDataSource = new kendo.data.DataSource({
        ...
        aggregate: [
            { field: "valueUSD", aggregate: "sum" }
        ],
        //group: function () {
        //    return {
        //        field: "deal.dealStatus",
        //        aggregates: [{
        //            field: "valueUSD",
        //            aggregate: "sum"
        //        }]
        //    };
        //},
        group:grouping,

Is this the way to go?  To dynamically change "grouping" based on grouping changes?

 

 Thanks

Chris

 

2 Answers, 1 is accepted

Sort by
0
Chris
Top achievements
Rank 1
answered on 16 Jun 2015, 02:54 PM

Just as some extra info.  I see from making the below example "groupable: true" that I must be missing something.  This example seems to behave as I want. whatever grouping I set via the GUI.

http://demos.telerik.com/kendo-ui/grid/aggregates

0
Rosen
Telerik team
answered on 18 Jun 2015, 08:49 AM

Hello Chris,

In order to change the groups dynamically and have aggregates, you will need to also declare the appropriate aggregate functions at the column aggregates configuration. This is shown in the online demo you have pointed.

Regards,
Rosen
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Chris
Top achievements
Rank 1
Answers by
Chris
Top achievements
Rank 1
Rosen
Telerik team
Share this question
or