Kendo grid hidden column in wrong position when exporting to excel

1 Answer 33 Views
Grid
Shane
Top achievements
Rank 1
Shane asked on 18 Aug 2022, 09:21 PM | edited on 19 Aug 2022, 01:54 PM

I have a kendo grid with a column that is not displayed in the grid, but is conditionally included when exporting to excel.

However, this column is positioned as the last column in the sheet, instead of being positioned as defined in the grid column definition.

I have no idea what the issue may be.

Any help will be greatly appreciated.



This is the method by which I am conditionally including the column in the excel export:

excelExport: (e: kendo.ui.GridExcelExportEvent) => {
    if (columnShouldShow) {
        e.sender.showColumn('MyColumn');
        e.preventDefault();
        columnShouldShow = false;
        setTimeout(() => {
            e.sender.saveAsExcel();
        });
    } else {
        e.sender.hideColumn('MyColumn');
        columnShouldShow = true;
    }
}

1 Answer, 1 is accepted

Sort by
0
Neli
Telerik team
answered on 23 Aug 2022, 01:50 PM

Hi Shane,

Could you please confirm which is the Kendo version used on your side? Note, that starting with the Kendo UI R1 2021 the Grid columns have an exportable configuration, which if enabled, will include the hidden column in the exported file.

- https://docs.telerik.com/kendo-ui/api/javascript/ui/grid/configuration/columns.exportable

Here you will find a small Dojo example where the last column is hidden, but is exported to Excel.

Please take a look at the provided suggestion and let me know if it is suitable for your scenario.

Regards,
Neli
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/.

Tags
Grid
Asked by
Shane
Top achievements
Rank 1
Answers by
Neli
Telerik team
Share this question
or