How to modify data before export with Buttons API?
How to modify data before export with Buttons API?
Link to test case: https://live.datatables.net/koyowiso/1/
Description of problem:
I am using the Buttons plugin to export a printable version and an Excel file. For the export I would like to modify the cell content, either the HTML created with
{
columns: [
{
data: function ...
}
]
}
or the original data object. In case of modifying the HTML, I'm thinking about adding a CSS class to the elements that should be removed from the export.
The only way that seems to come close is exportOptions
from the Buttons API, but I cannot figure out how to modify the data before export. Could you please give a hint?
This question has an accepted answers - jump to answer
Answers
I discovered now the
customize: (window, button, dt) => {...}
option but I cannot select the elements that I want to remove from the DOM of the print window withwindow.document.body.querySelectorAll('.noexport');
because the HTML has already been cleaned.I managed to do it with
exportOptions
, see: https://live.datatables.net/sumolevi/2/editThe comments brought me on the right track.
Hi,
Thanks for the update. Good to hear you found a solution!
Allan