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

Error Exporting to Excel

5 Answers 601 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Eduardo
Top achievements
Rank 1
Eduardo asked on 15 Apr 2017, 02:12 AM

Hello All,

I have the following groupFooterTemplate:

groupFooterTemplate: '<div style="text-align: right;">#=data.col01.group.value# #=kendo.toString(sum, "n0")#</div>'

 

It works perfectly, but when I export to Excel, I get the following error:

VM49544:3 Uncaught TypeError: Cannot read property 'value' of undefined
    at Object.eval [as groupFooterTemplate] (eval at compile (kendo.all.js:194), <anonymous>:3:131)

What am I doing wrong?

Cheers.

Edo.

5 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 18 Apr 2017, 10:53 AM
Hello Eduardo,

Please have in mind that exporting template column is a known limitation of the Grid Excel export feature. In this scenario the used HTML will be exported as well:

http://docs.telerik.com/kendo-ui/controls/data-management/grid/excel-export#limitations

If the Grid is exported with a regular template, the values should be exported as expected:

http://dojo.telerik.com/Aruwu

If the issue still occurs, please modify the provided example or send a new one reproducing the issue and I will gladly assist.

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.
0
Eduardo
Top achievements
Rank 1
answered on 19 Apr 2017, 08:42 PM

Stefan,

Thank you for your answer.

It "almost" works.

This is my export function:

excelExport: function (e) {
    console.log("Export starting...");
    var rows = e.workbook.sheets[0].rows;
 
    for (var ri = 0; ri < rows.length; ri++) {
        var row = rows[ri];
        if (row.type == "group-footer" || row.type == "footer") {
            for (var ci = 0; ci < row.cells.length; ci++) {
                var cell = row.cells[ci];
                if (cell.value) {
                    console.log("DATA: " + cell.value);
                    cell.value = $(cell.value).text();
                    console.log("DATA: " + cell.value);
                    cell.hAlign = 'right';
                }
            }
        }
    }
},

 

This works for a group footer template where I'm not using the group row label, like the following:

groupFooterTemplate: '<div style="text-align: right;">#=kendo.toString(sum, "n0")#</div>', footerTemplate: '<div style="text-align: right;">#=kendo.toString(sum, "n0")#</div>'

 

However, it doesn't work in this other template:

groupFooterTemplate: '<div style="text-align: right;">#=(typeof data.col01.group.value != "undefined" ? data.col01.group.value : "")# #=kendo.toString(sum, "n0")#</div>', footerTemplate: '<div style="text-align: right;">#=kendo.toString(sum, "n0")#</div>'

 

In this later case, the export function is not called and I get the following error:

Uncaught TypeError: Cannot read property 'value' of undefined
    at Object.eval [as groupFooterTemplate] (eval at compile (kendo.all.js:194), <anonymous>:3:139)
    at init.<anonymous> (kendo.all.js:11943)
    at d (jquery.min.js:2)
    at Function.map (jquery.min.js:2)
    at init._footer (kendo.all.js:11937)
    at init._dataRow (kendo.all.js:11914)
    at init._dataRows (kendo.all.js:11932)
    at init._dataRow (kendo.all.js:11907)
    at init._dataRows (kendo.all.js:11932)
    at init._dataRow (kendo.all.js:11907)

 

Is there anything than can be done in this case?

Cheers.

0
Stefan
Telerik team
answered on 21 Apr 2017, 02:12 PM
Hello Eduardo,

I was able to reproduce the same error on my end and it occurs because the group value used in the template is not available for the export.

I forwarded to our developers' team for further investigation if this is an issue with the export.

I will provide more information as soon as I receive the report from the team. 

Thank you in advance for your patience.

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.
0
Stefan
Telerik team
answered on 26 Apr 2017, 07:15 AM
Hello Eduardo,

As this may take more time to investigate I created an issue in our GitHub repository for better visibility.You can track its progress at:

https://github.com/telerik/kendo-ui-core/issues/3095

Additionally, I updated your Telerik points for bringing this to our attention.

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.
0
Eduardo
Top achievements
Rank 1
answered on 27 Apr 2017, 09:29 PM

Stefan,

Thank you.

I look forward to the team news.

 

Edo.

Tags
Grid
Asked by
Eduardo
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Eduardo
Top achievements
Rank 1
Share this question
or