Hiding first column and getting only visible columns for export

Hiding first column and getting only visible columns for export

fatihalpfatihalp Posts: 8Questions: 2Answers: 1

First column is remain for operations and and unneeded to export.
But get only the visible columns of displaying by the user and export it.

https://datatables.net/extensions/buttons/examples/print/columns.html
Simple with this example I need to also hide first column. Thanks!

Replies

  • profstyleprofstyle Posts: 1Questions: 0Answers: 0
    edited May 2016

    Good question pal !

  • fatihalpfatihalp Posts: 8Questions: 2Answers: 1

    If I able to hide column just before print It could also solves the problem.

    column.visible(false); 
    

    Where could I put this action to want to run just before action.

  • jr42.gordonjr42.gordon Posts: 305Questions: 2Answers: 49

    In the example you linked to, try adding a class to each <th> that you want printed "print-col". Then modify the exportOptions to following:

    exportOptions: {
          columns: '.print-col:visible'
    }
    
  • fatihalpfatihalp Posts: 8Questions: 2Answers: 1

    Gordon very clever method but datatables gives an error. Jsfiddle example:

    https://jsfiddle.net/9ehyrtv3/1/

  • fatihalpfatihalp Posts: 8Questions: 2Answers: 1

    Changed the order and it works thanks a lot Gordon! :)

    columns: ':visible.print-col'

This discussion has been closed.