Don't export hidden column
Don't export hidden column

is there a smart code for do this:
$(document).ready(function() {
$('#example').DataTable( {
dom: 'Bfrtip',
buttons: [
{
extend: 'copyHtml5',
exportOptions: {
columns: [ 0, ':visible' ]
}
},
{
extend: 'excelHtml5',
exportOptions: {
columns: ':visible'
}
},
{
extend: 'pdfHtml5',
exportOptions: {
columns: [ 0, 1, 2, 5 ]
}
},
'colvis'
]
} );
} );
i need to not export hidden column for all button... in there a manner to define this rule only one (not reply for all button)?
I want define columns: [ 0, ':visible' ] for all button
my code actually is:
.....
"dom": "Bfrtip",
"buttons": [
"copy", "csv", "excel", "pdf", "print"
],
....
Thanks
This discussion has been closed.
Answers
Each button is independent so you do need to define the
exportOptions
for each one. You can modify the defaults, as shown in this thread, but you would still need to do it for each button.One option, to avoid code duplicate is create an object that contains the
exportOptions
, then just use it for each, something like:Colin