I am using the 'Print' button in Jquery datatables and I am trying to programmatically change the 'Print' button's print page title. This is how i configure it the first time.
var table = $('table').DataTable({
buttons: [
extend: 'print',
title: 'Monthly Report' // need to change this
]
});
So basically i need to change the title using the API. Note that this title is not the text on the button. It is the title on the print page. (The page that shows up when i click the 'Print' button)
I've already tried to change the title using the API like this
table.api().buttons()[0].inst.c.buttons[0].title = 'Daily Reports';
But its not working. Any help would be much appreciated.
Looking at the source code of datatables it seemed that the config of the buttons is set at initialization. So changing the config as you are doing wouldn't work.
What the source code did reveal though is that you can set the title as a function. So I suggest something like this might solve the issue:
var table = $('table').DataTable({
buttons: [
extend: 'print',
title: function(){
return foo.title
}
]
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With