Reputation: 8538
I have a Datatable in Bootstrap3 Framework. I would like to give an option to print the datatable through a Print button.
Here is the jquery instantiation of my datatable
$('#dataTables-example').DataTable({
'buttons': ['excel', 'pdf', 'print'] });
However, the button for print doesnt fit into my theme and would like to trigger the datatable print function through a custom print button. Any idea how this can be achieved ?
Reference : Documentation for Datatable Print
Upvotes: 2
Views: 6528
Reputation: 4205
You should add custom print button event like this:
Button
<button id="btnPrint">Custom Print Button</button>
JS
/* custom button event print */
$(document).on('click', '#btnPrint', function(){
$(".buttons-print")[0].click(); //trigger the click event
});
You can see live demo here: https://output.jsbin.com/cozadek
https://jsbin.com/cozadek/13/edit?html,output
Upvotes: 3