I have a grid which displays a summary of data along with totals and subtotals.
I want to add this drill-down functionality to the sub-total rows, but I need to pass the value of the aggregating field (in my case the patient class field). However, I'm not able to reference this field in the ClientGroupFooterTemplate.
This works passing a string ("-X-" - which shows all values), but I need to pass the patient class value relating to the sub-total. How can I do this?
23 Answers, 1 is accepted
In case this helps anyone else, I got the solution after raising a support ticket.
You need to use the DataBinding event, and use a function to set the value:-
This is incredibly helpful. However, after implementing this solution and i try to export the data to excel, i get the following error:
Uncaught ReferenceError: groupField is not defined
at Object.eval [as groupFooterTemplate] ....
Here is an easier way to access the grid's aggregates:
I found this solution to be very helpful, however it only works for me if you are using a single column to group by.
My problem is that I have a grid that allows the user to select multiple columns to group by. There is a lot of data behind this grid, and it doesn't fit on any single page, so without using the example above, the users would only see (at the end of a 4 column grouping) 4 lines of: Total W: 100 / Total X:1000 / Total Y:10,000 / Total Z: 100,000. It's nice to be about to know what the totals are for. I think its odd that the Kendo grid can't display this, even thought it is available in the header of the group.
The attached images show: 1) what you see without using the code.. .just line after line of 'Totals', with no description. 2) what you see using the code above with 1 grouping - looks great! and 3) what you see if you group on 2 items.
What appears to happen, is that even though you are grouping now on 2 items, there is really only 1 grouping column (should be 2), and all the contents of the grid get shifted to the left, leaving and empty column on the right. I have an idea that there are basically 2 tiers now in the aggregate, and I am overwriting it with a single grouping, and the grid header is expecting (cols+2) columns, but is only getting (cols+1) of data. Now in writing this post up I just did discover that using this code is putting the grid in some error state that leaves it unresponsive, which I plan on debugging next.
I've tried to stringify the aggregate object to see if there was a way that I could pull out the correct grouping name for the different groups, but nothing is standing out as useful information.
Does anyone have any sample code or information on the aggregates object that might point me in the direction to working with a more complex grouping that 1 column?
FYI.. the 2nd and 3rd images got switched... so the 2nd image actually shows what happens when grouping on 2 columns.
Thank you for the provided screenshots.
It is possible to access the group field nowadays without using any event handlers as the group data is readily available in the group footer template:
I created a similar example to your scenario as I understand it and you can group by four fields and see the group footer template get updated correctly:
I did notice one pressing issue with this solution. When I add "#=data.ProductName.group.field #" to the ClientGroupFooterTemplate, The Excel Export stops working (if Groupings are selected).
So if I use: .ClientGroupFooterTemplate( "Totals for #=data.ProductName.group.field #: #=data.ProductName.group.value #") the screen looks great if groupings are selected (or not). But Exporting will only work if there are no current Groupings selected. If there are groupings selected, nothing happens when you hit the 'Export to Excel' button.
If I remove the #=data.ProductName.group.field # and #=data.ProductName.group.value # from the ClientGroupFooterTemplate, the Export works now fine when Groupings are selected, but then I am back to my original issue of not being about to see the Grouping info in the footer.
So, adding #=data.ProductName.group.field # to the ClientGroupFooterTemplate breaks the built in Excel Export. Interesting enough, I found some other examples of using IWorksheetExporter and SpreadDocumentFormat, but these seem to work and fail using the same scenarios.
I found this: https://www.telerik.com/forums/export-to-excel-not-working-with-clientgroupfootertemplate-and-data-variable
I wasn't running the latest build, so I will try upgrading tomorrow.
Flagging my post as a duplicate. My issue may be fixed in a more current version: https://www.telerik.com/forums/export-to-excel-not-working-with-clientgroupfootertemplate-and-data-variable
I wasn't running the latest build, so I will try upgrading tomorrow and see if the issue persists.
Thank you for bringing the Excel Export to my attention. Upgrading to the latest version is always recommended, however, in this particular case, the issue you are experiencing is due to the different format of the data object during the excel export. (The data in the excel export was enhanced in 2017 R3 SP1)
I will discuss this with the Principal Excel Export engineer whether we can amend the data object during excel export at the beginning of next year(after the holidays). Meanwhile, you can add a condition to the template, for example:
I have updated the Dojo:
Please accept my apology for any inconvenience caused.
Thank you very much for your feedback, I am glad to hear you found the last suggestion helpful.
I will update this forum thread once I have more information.
Happy New Year!
I have spoken with the Principal Excel Export Engineer and reopened an old issue which was addressing the same topic. It will be investigated shortly and you can monitor its progress at:
Once the fix is applied, it will be tested and a new milestone will be set so you know when to expect the fix.
The Kendo UI Grid for ASP.NET MVC also has that as part of the GridColumnBuilder. The group footer is available as ClientGroupFooterTemplate:
ClientFooterTemplate("Total for #=data.group.field #), but it is not working.
The recommended property to use is the ClientGroupFooterTemplate.
If you want to access the field by which the grid is currently grouped by, you can do that with the following syntax:
Let me know in case further questions arise.
Hi Alex, Thanks for the help. Finally, I am able to use the groups name in ClientGroupFooterTemplate. I was missing the aggregates function for the group name field.
Everything looks good but with this change (reported by the other users as well), Excel Export has stopped working.
This is the template I am using: ClientGroupFooterTemplate("#=data.Operation.group ? data.Operation.group.field: data.group.field # Totals:");
With the latest version, the syntax works well out of the box - anything available in the template will be available in the excel export cell as well, you can see that in the UnitsOnOrder group footer template: