Excel Export not working with ClientGroupFooterTemplate that references a Kendo value

1 Answer 44 Views
Top achievements
Rank 1
Greg asked on 02 Aug 2021, 02:06 PM | edited on 04 Aug 2021, 07:20 PM

I'm using a Kendo MVC grid with columns defined as follows:

columns.Bound(p => p.PoolId).Title("Pool").Hidden(true);

columns.Bound(p => p.Client).Title("Client").HtmlAttributes(new { @style = "min-width:120px;" })
    .ClientGroupFooterTemplate("<div class=aright>#:value# Totals:</div>");

With a group on the "PoolId" field:


.Group(group => group.Add(g => g.PoolId))


Excel export works when I don't reference any Kendo values in the ClientGroupFooterTemplate (or don't include the footer template at all) but just silently fails (doesn't generate a file) when I try to reference any Kendo value using '#='

For example, the following works:

columns.Bound(p => p.Client).Title("Client").HtmlAttributes(new { @style = "min-width:120px;" })
    .ClientGroupFooterTemplate("<div class=aright>Totals:</div>");

but the following is another example of a footer that fails:

columns.Bound(p => p.Client).Title("Client").HtmlAttributes(new { @style = "min-width:120px;" })
    .ClientGroupFooterTemplate("<div class=aright>#= kendo.format('{0:C}', aggregates.PoolContributions.min) #</div>");

How do I get the Excel export working with ClientGroupFooterTemplate?

I'm using Kendo UI MVC version 2021.2.511.545

NOTE: PDF exports work properly

ALSO NOTE: I see the following error in the console

Uncaught ReferenceError: value is not defined
    at Object.eval [as groupFooterTemplate] (eval at compile (kendo.all.js:234), <anonymous>:3:82)
    at kendo.all.js:15113
    at Array.map (<anonymous>)
    at init._footer (kendo.all.js:15107)
    at init._dataRow (kendo.all.js:14952)
    at init._dataRows (kendo.all.js:15005)
    at init._rows (kendo.all.js:15245)
    at init.workbook (kendo.all.js:14865)
    at init.<anonymous> (kendo.all.js:15382)
    at Object.d (jquery.min.js:2)

1 Answer, 1 is accepted

Sort by
Ivan Danchev
Telerik team
answered on 05 Aug 2021, 06:45 AM

Hello Greg,

In the ClientGroupFooterTemplate you don't have access to "value", which is why you get the "undefined" exception. The fields you can access are:

  • average - the value of the "average" aggregate (if specified)
  • count - the value of the "count" aggregate (if specified)
  • max - the value of the "max" aggregate (if specified)
  • min - the value of the "min" aggregate (if specified)
  • sum - the value of the "sum" aggregate (if specified)
  • data - provides access to all available aggregates, e.g. data.fieldName1.sum or data.fieldName2.average
  • group - provides information for the current group. An object with three fields - field, value and items. items field contains the data items for current group. Returns groups if the data items are grouped (in case there are child groups)

Through the "group" field you can access the value and it would look like this:

.ClientGroupFooterTemplate("Value #: data.PoolId.group.value #");

Ivan Danchev
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Top achievements
Rank 1
commented on 05 Aug 2021, 01:42 PM

Thank you. I finally determined that the Excel export and the on-screen data models were different. What I ended up using was a footer like the following:

.ClientGroupFooterTemplate("#if (data !== undefined && data.group !== undefined) {##:group.value# Totals:# } else if (data !== undefined) {##:value# Totals:# }#")

value was accessible when rendering on-screen but I had to use group.value during Excel exports.

Ivan Danchev
Telerik team
commented on 10 Aug 2021, 08:52 AM

Glad to see you sorted it out with conditional logic in the template. Thank you for sharing your approach.
Asked by
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Share this question