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

Multiple aggregates in groupHeaderTemplate

12 Answers 1400 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jonathan
Top achievements
Rank 1
Jonathan asked on 20 Jun 2012, 04:25 AM
Is it possible to have multiple aggregates from different columns in the groupHeaderTemplate?

In this example, I can get the count of campaigns in the header, but I would like to have sum of the AmountReceived also in the groupheader. Is this possible

$(document).ready(function () {
 
       $("#grid").kendoGrid({
           dataSource: {
               type: "json",
               transport: { read: "GetData" },
               group: [{
                   field: "Campaign_Desc",
                   aggregates: [
                       { field: "Campaign_Desc", aggregate: "count" },
                       { field: "AmountReceived", aggregate: "sum" },                       
                   ]
               }],
               aggregate: [
                       { field: "Campaign_Desc", aggregate: "count" },
                       { field: "AmountReceived", aggregate: "sum" },
                   ]
           },
 
           columns: [
              { field: "DonorName", title: "Donor" },
              { field: "DateReceived", title: "Date" },
               { field: "ReceiptNbr", title: "Rcpt #" },
               { field: "AmountReceived", title: "Amount", footerTemplate: "Total: #=sum#", groupFooterTemplate: "Total: #=sum#" },
               { field: "Campaign_Desc", title: "Campaign", footerTemplate: "Total Count: #=count#", groupHeaderTemplate: "<b>#= value #</b> -  Count: #=count#" },
               { field: "Source_Desc", title: "Source" },
               { field: "TenderType_Desc", title: "Tender" },
               { field: "CheckNumber", title: "Check #" },
               { field: "GLBatchNumber", title: "Batch" }
          ],
           scrollable: false,
           sortable: true,
           filterable: true
 
 
       });
 
   });

12 Answers, 1 is accepted

Sort by
0
Garrett
Top achievements
Rank 2
answered on 22 Jun 2012, 04:57 AM
I have the same problem, I can put multiple aggregates in the groupFooterTemplate, but not the header. Anyone have an idea if this is possible?
0
Iliana Dyankova
Telerik team
answered on 22 Jun 2012, 09:44 AM
Hi guys,

I am afraid that the described functionality is not supported. Only the aggregates from the grouped column can be displayed in the groupHeaderTemplate.

Regards,
Iliana Nikolova
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Jonathan
Top achievements
Rank 1
answered on 22 Jun 2012, 01:01 PM
Is there a way to put the value of the grouped field and an aggregate of another field? So if I group by field category but I wanted to put the sum of price. Is that possible?

If not is there a way to show the group footer when collapsed? 
0
Iliana Dyankova
Telerik team
answered on 26 Jun 2012, 02:25 PM
Hi Jonathan,

As I mentioned in my previous post, only the aggregates from the grouped column can be displayed in the groupHeaderTemplate. 

Regarding the "is there a way to show the group footer when collapsed" question - I am afraid such functionality is currently not supported, however this idea has been already submitted at KendoUI UserVoice forum, so if you wish you may cast a vote for it or leave a comment. The more votes it collect, the higher priority it will have. 
  
Regards,
Iliana Nikolova
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Feroz
Top achievements
Rank 1
answered on 05 Jun 2013, 10:44 PM
Hi,
I'm facing exactly the same issue. My grouping is on EmployeeHomeSite. But I also need the TotalHours in the group header. What I tried doing is, as you can see in the below code, in the groupFooterTemplate of TotalHours, I called a javascript function and set a global variable.. and in the groupHeaderTemplate of EmployeeHomeSite, I'm retrieving it and displaying.. As expected it is displaying undefined for the frist grouping and the total of first grouping is being displayed on second grouping.. Taking this ahead more, I'm trying to get the total by using jquery selection method and calculting the total.. but no success so far.. Anybody got better ideas?

                    $("#grid_temp").kendoGrid({
                        dataSource: dataSource,
                        columns: [
                            { field: "TransactionType", title: "Transaction Type" },
                            {
                                field: "TotalHours", title: "Total Hours", attributes: { style: "text-align:right;" },
                                groupFooterTemplate: "#=assignTotalHours(sum)#"
                            },
                            {
                                field: "EmployeeHomeSite",  groupHeaderTemplate: "Total Hours = #=computeTotalHours(value)# "
                            }
                        ]
                    });
                });
0
Iliana Dyankova
Telerik team
answered on 10 Jun 2013, 05:44 PM
Hello Feroz,

As I mentioned in the previous posts, the described functionality is not supported in Kendo UI Grid and unfortunately there is no suitable workaround which I can suggest. Please accept my apologies for the inconvenience caused.
 
Regards,
Iliana Nikolova
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Ben
Top achievements
Rank 1
answered on 20 Nov 2013, 03:55 PM
Hi,
I realise this question was originally asked a while ago, but can you confirm whether there are any plans to make this functionality available?   It would be extremely useful to be able to display aggregate values in their respective columns in the group header.

Thanks
0
Iliana Dyankova
Telerik team
answered on 25 Nov 2013, 02:10 PM
Hi Ben,

I have posted a reply in your support ticket, however I am pasting my reply here too: 

The implementation of this feature is not in our immediate plans, however we will appreciate it if you submit this idea as a feature request at Kendo UI UserVoice page - this way the community would be able to vote and comment it. When planning for a release we gather and take into account all the feedback from UserVoice - the more votes the suggestion collects, the higher priority will have.

Meanwhile as a possible workaround I can suggest calling a JavaScript function from within the groupHeaderTemplate and manually extract the dataSource aggregates using the dataSource API.


Regards,
Iliana Nikolova
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Bill
Top achievements
Rank 2
answered on 15 May 2014, 08:26 PM
Iliana, following your suggestion, how do you get to the group aggregate values?  I can only manage to get the grid aggregates.

http://trykendoui.telerik.com/iFEq

If I use the debugger to inspect the dataSource, I can find the group aggregate definitions, but never the values.

working example for grid aggregate, 
columns: [
                          { field: "CategoryID", title: "CategoryID"
                            , groupHeaderTemplate: function(dataSource) { 
                              var grid = $("#grid").data("kendoGrid"); 
                              var ds = grid.dataSource; 
                              debugger; 
                              var x = ds.aggregates().UnitPrice.sum - ds.aggregates().UnitsOnOrder.sum;
return "Bal: " + kendo.toString(x, '0.00');
                                }
                          },


0
Iliana Dyankova
Telerik team
answered on 20 May 2014, 04:41 PM
Hi Bill,

If I understand correctly you would like to display the aggregated values for each group in the groupHeaderTemplate? If this is the case I am afraid it is not supported by Kendo UI Grid. If I am missing somethong please elaborate a bit more on the exact outcome you would like to achieve - this way I would be able to advice you further? 

Regards,
Iliana Nikolova
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Gaerik
Top achievements
Rank 1
answered on 15 Feb 2015, 09:31 AM
Hi,

I understand this is a very old thread, but would like to know, if this feature has been implemented in the latest release. 
I am trying to display the aggregate value from field different from the one that has been used to group the data and I am unable to see it. 

JSFiddle Sample:   http://jsfiddle.net/gaerik25/aqeL8hef/6/

Thanks,
Gaerik




0
Iliana Dyankova
Telerik team
answered on 19 Feb 2015, 07:54 AM
Hi Gaerik,

With the current implementation of Kendo UI Grid only the aggregates from the grouped column can be displayed in the groupHeaderTemplate. The idea for multiple aggregates has been submitted as a feature request at our UserVoice portal - you may cast a vote, leave a comment or monitor the community's interest in it here

Regards,
Iliana Nikolova
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
Jonathan
Top achievements
Rank 1
Answers by
Garrett
Top achievements
Rank 2
Iliana Dyankova
Telerik team
Jonathan
Top achievements
Rank 1
Feroz
Top achievements
Rank 1
Ben
Top achievements
Rank 1
Bill
Top achievements
Rank 2
Gaerik
Top achievements
Rank 1
Share this question
or