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

Grid export columns without hiding

1 Answer 100 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Baba
Top achievements
Rank 1
Baba asked on 17 Nov 2016, 09:54 AM

Hello,

I'm trying to export some columns in a grid without hiding them. Now I'm using something like this:

 var $grid = $('#grid').data('kendoGrid');

for(var i=0; i<columnsthatIdontneed.lenght;i++){

$grid.hideColumn(columnsthatIdontneed[i]);

}

 $grid.saveAsExcel();//or $grid.saveAsPDF();

for(var i=0; i<columnsthatIdontneed.lenght;i++){
$grid.showColumn(columnsthatIdontneed[i]);
}

I need a solution for export without hiding those columns.

Thanks.

1 Answer, 1 is accepted

Sort by
0
Alex Hajigeorgieva
Telerik team
answered on 18 Nov 2016, 11:33 PM
Hello Baba,

There is another way that I can think of achieving hidden columns. 

You can add an event handler function to the excelExport event and loop over the cells of the workbook and remove the ones you do not wish to export. The workbook is available in the event data.

I created a demo with a boolean array which holds the columns that need to be hidden for quick and easy reference. Then if the current cell has the column index of a column that needs to be hidden, remove it from the workbook.

My demo is available at:

http://dojo.telerik.com/IDeFa/2

Kind Regards,
Alex Hajigeorgieva
Telerik by Progress
Kendo UI is ready for Visual Studio 2017 RC! Learn more.
Tags
Grid
Asked by
Baba
Top achievements
Rank 1
Answers by
Alex Hajigeorgieva
Telerik team
Share this question
or