Multiple aggregates in groupHeaderTemplate

Thread is closed for posting
13 posts, 0 answers
  1. Jonathan
    Jonathan avatar
    57 posts
    Member since:
    Jun 2012

    Posted 19 Jun 2012 Link to this post

    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
     
     
           });
     
       });
  2. Garrett
    Garrett avatar
    7 posts
    Member since:
    Apr 2012

    Posted 21 Jun 2012 Link to this post

    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?
  3. Kendo UI is VS 2017 Ready
  4. Iliana Nikolova
    Admin
    Iliana Nikolova avatar
    2592 posts

    Posted 22 Jun 2012 Link to this post

    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!
  5. Jonathan
    Jonathan avatar
    57 posts
    Member since:
    Jun 2012

    Posted 22 Jun 2012 Link to this post

    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? 
  6. Iliana Nikolova
    Admin
    Iliana Nikolova avatar
    2592 posts

    Posted 26 Jun 2012 Link to this post

    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!
  7. Feroz
    Feroz avatar
    6 posts
    Member since:
    Jun 2013

    Posted 05 Jun 2013 Link to this post

    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)# "
                                }
                            ]
                        });
                    });
  8. Iliana Nikolova
    Admin
    Iliana Nikolova avatar
    2592 posts

    Posted 10 Jun 2013 Link to this post

    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!
  9. Ben
    Ben avatar
    1 posts
    Member since:
    Jan 2013

    Posted 20 Nov 2013 Link to this post

    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
  10. Iliana Nikolova
    Admin
    Iliana Nikolova avatar
    2592 posts

    Posted 25 Nov 2013 Link to this post

    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!
  11. Bill
    Bill avatar
    31 posts
    Member since:
    Mar 2013

    Posted 15 May 2014 in reply to Iliana Nikolova Link to this post

    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');
                                    }
                              },


  12. Iliana Nikolova
    Admin
    Iliana Nikolova avatar
    2592 posts

    Posted 20 May 2014 Link to this post

    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!
     
  13. Gaerik
    Gaerik avatar
    1 posts
    Member since:
    Feb 2015

    Posted 15 Feb 2015 Link to this post

    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




  14. Iliana Nikolova
    Admin
    Iliana Nikolova avatar
    2592 posts

    Posted 19 Feb 2015 Link to this post

    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!
     
Back to Top
Kendo UI is VS 2017 Ready