Monday, 21 March 2022

jQuery Datatable extend print button to work for multiple tables on same page

I've 1 to n tables in a HTML page and want to print all of them in one flow. jQuery Datatables delivers a "build-in" print button but this only works for the assigned table. However, there must be some logic behind to collect all the data from the rows and print them.

Is it possible to extend this logic to work for several tables on the same page?

I've created this fiddle as a playground.

This is the build in print button logic:

$('#example').DataTable( {
    dom: 'Bfrtip',
    buttons: [
        'print'
    ]
} );

Those 2 minified js are needed to make the button work: https://cdn.datatables.net/buttons/2.2.2/js/dataTables.buttons.min.js https://cdn.datatables.net/buttons/2.2.2/js/buttons.print.min.js



from jQuery Datatable extend print button to work for multiple tables on same page

No comments:

Post a Comment