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

Hide column from export Excel (Grid MVVM)

3 Answers 1952 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Federico
Top achievements
Rank 1
Federico asked on 31 Oct 2017, 04:41 PM
<div id="GridIdt" data-role="grid"
             data-toolbar="['excel']"
             data-excel='{fileName: "doc.xlsx", proxyURL: "http://demos.telerik.com/kendo-ui/service/export",filterable: true}'
             data-columns="[
                        { 'field': 'name','title':'Nome',width:200},
                        { 'field': 'surname','title':'Cognome',excel:false},
                        { 'field': 'empty','title':'Stato',width:140}
                         ]"
             data-bind="source: GridSource">

I'd like to remove 'Cognome' from excel file. How hide this column in the excel file?

And ,also, i'd like to remove 'Nome' from the view of grid.

excel: name and empty.

grid: surname and empty.

datasource: name,surname and empty.

How I can do this? 'excel:false' doesn't work!

3 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 02 Nov 2017, 11:37 AM
Hello, Federico,

The columns can be removed from the exported file using a custom logic on the excelExport event. More details and code can be found in the following forum thread. The MVVM approach is the same as it is using standard JavaScript and jQuery:

https://www.telerik.com/forums/export-to-grid-hide-columns

Also, a column can be hidden initially using the columns.hidden property of the Grid:

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

I hope this is helpful.

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Federico
Top achievements
Rank 1
answered on 02 Nov 2017, 02:39 PM
Can you create a demo please? i try to do like example but my code doesn't work!
0
Stefan
Telerik team
answered on 06 Nov 2017, 08:49 AM
Hello, Federico,

I made an example following the suggested approach and it is working as expected. Column "ProductID" is hidden initially and shown in the export, the "ProductName" column is shown initially and hidden in the exported file:

http://dojo.telerik.com/Asaxi


Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Federico
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Federico
Top achievements
Rank 1
Share this question
or