Override default button export options?
Override default button export options?

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.
This discussion has been closed.
Answers
That worked - some javascript issues on my end.
Your example code seems to work here:
http://live.datatables.net/qucuqipo/1/edit
Can you provide a link to your page or a test case showing the issue?
Kevin
It does work as I commented - I sure wish you could edit your posts.
I would edit this to ask if you can override just the column exportOptions vs having to re-initialize all the button options.