Hide column from export Excel (Grid MVVM)

4 posts, 0 answers
  1. Federico
    Federico avatar
    21 posts
    Member since:
    Oct 2017

    Posted 31 Oct 2017 Link to this post

    <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!

  2. Stefan
    Admin
    Stefan avatar
    2491 posts

    Posted 02 Nov 2017 Link to this post

    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.
  3. Federico
    Federico avatar
    21 posts
    Member since:
    Oct 2017

    Posted 02 Nov 2017 Link to this post

    Can you create a demo please? i try to do like example but my code doesn't work!
  4. Stefan
    Admin
    Stefan avatar
    2491 posts

    Posted 06 Nov 2017 Link to this post

    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.
Back to Top