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

Kendo Grid Multilevel grouping with different aggregates per group level

3 Answers 2106 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dipti
Top achievements
Rank 1
Dipti asked on 06 Jul 2016, 10:34 AM
In the Kendo Grid, it looks like we can group the data by multiple columns so that we have multiple levels of grouping. However, when we apply an aggregate, currently it is being applied at all the grouping levels. So, can someone please let me know if I can have different aggregates for different group levels. For example, if we have grouped data by say two columns, “UnitsInStock” and “UnitsOnOrder”, is it possible to show say Count of “ProductName” at the “UnitsOnOrder” grouping level and may be Sum of “UnitPrice” at the “UnitsInStock” group. 

Following is the snippet that shows how I am doing the grouping in Kendo grid.

        <script>
                $(document).ready(function() {
                    $("#grid").kendoGrid({
                        dataSource: {
                            type: "odata",
                            transport: {
                                read: "http://demos.telerik.com/kendo-ui/service/Northwind.svc/Products"
                            },
                            schema:{
                                model: {
                                    fields: {
                                        UnitsInStock: { type: "number" },
                                        ProductName: { type: "string" },
                                        UnitPrice: { type: "number" },
                                        UnitsOnOrder: { type: "number" },
                                        UnitsInStock: { type: "number" }
                                    }
                                }
                            },
                            pageSize: 100,
                            group: [{
                                     field: "UnitsInStock", aggregates: [
                                        { field: "UnitPrice", aggregate: "sum"},
                                     ]
                            },
                                    { field: "UnitsOnOrder", aggregates: [
                                        { field: "ProductName", aggregate: "count" },
                                        { field: "UnitPrice", aggregate: "sum"},
                                        { field: "UnitsOnOrder", aggregate: "sum" },
                                        { field: "UnitsInStock", aggregate: "count" }
                                     ]
                                   }],

                            aggregate: [ { field: "ProductName", aggregate: "count" },
                                          { field: "UnitPrice", aggregate: "sum" },
                                          { field: "UnitsOnOrder", aggregate: "sum" },
                                          { field: "UnitsInStock", aggregate: "min" },
                                          { field: "UnitsInStock", aggregate: "max" }]
                        },
                        sortable: true,
                        scrollable: false,
                        pageable: true,
                      groupable:false,
                        columns: [
                            { field: "ProductName", title: "Product Name", aggregates: ["count", "average" ], footerTemplate: "Total Count: #=count#", groupFooterTemplate: "Count: #=count#" },
                            { field: "UnitPrice", title: "Unit Price", aggregates: ["sum"],footerTemplate: "Sum: #=sum#",
                                groupFooterTemplate: "Sum: #=sum#" },
                            { field: "UnitsOnOrder", title: "Units On Order", aggregates: ["average", "sum"], footerTemplate: "Sum: #=sum#",
                                groupFooterTemplate: "Sum: #=sum#" },
                            { field: "UnitsInStock", title: "Units In Stock", aggregates: ["min", "max", "count", "average"], footerTemplate: "<div>Min: #= min #</div><div>Max: #= max #</div>",
                                groupHeaderTemplate: "Units In Stock: #= value # " +  
                             "(Sum: #= aggregates.UnitPrice.sum #)" }
                        ]
                    });
                });
                 
            </script> 

Looking forward to your suggestions.

Thank You

3 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 08 Jul 2016, 12:28 PM
Hello Dipti,

Thank you for the interest in Kendo UI.

Displaying different aggregates for the different group levels in the Kendo UI Grid is currently not supported. Indeed this is on our to-do list, and it will be available in the next major release which is expected in the middle of September.

Let me know if you need additional information on this matter.

Regards,
Stefan
Telerik by Progress
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
0
David
Top achievements
Rank 1
answered on 17 Jan 2017, 01:55 PM

Hi,

Has this functionality been released?

Cheers

0
Stefan
Telerik team
answered on 19 Jan 2017, 07:52 AM
Hello David,

I can suggest checking the columns.groupHeaderTemplate property of the Grid where all of the defined aggregates are available, and they can be displayed as desired:

http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#configuration-columns.groupHeaderTemplate

Regards,
Stefan
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data (charts) and form elements.
Tags
Grid
Asked by
Dipti
Top achievements
Rank 1
Answers by
Stefan
Telerik team
David
Top achievements
Rank 1
Share this question
or