Almost all my datatables have the last two columns that I don't want to print etc. I did this:
$.extend($.fn.dataTable.defaults, {
buttons: {
buttons: [
{
extend: 'print',
exportOptions: {
columns: [':lt(-2)']
}
}
]
}
});
I have a default call on a class that loads the datatable.
Now I have the odd table that I want to clear this and print all columns. So I clear that class and manually initialize:
$('#odd_table').dataTable({
buttons: {
buttons: [
{
extend: 'print',
text: '<i class="far fa-print"></i> Print',
orientation: 'landscape',
exportOptions: {
columns: [0, 1]
}
}
]
}
});
No mater what I specify in the exportOptions the default options are applied. I figured this was as easy as changing the default settings.