Update column for print when using colvis
Update column for print when using colvis
Hello,
I am using Colvis to show and hide columns, it works well but when I want to print or export the datable the columns are not updated.
I have tried to add a variable at the beginning of my code and do something like that :
$('#datatables-buttons').on( 'column-visibility.dt', function ( e, settings, column, state ) {
$('#datatables-buttons').DataTable().columns().every( function () {
if (this.visible()) {
columns_export.push(this.index());
}
} );
console.log(columns_export);
} );
But it does not work and I imagine there is something cleaner or out of the box.
Thank you !
Answers
See if this example helps.
Kevin