When using the print button, is there any way to show table headers on every page?
When using the print button, is there any way to show table headers on every page?
I'm pessimistic about this, but thought I'd ask anyway.
I'm using the 'print' button[1] with my table, and it works fine. However, my typical use-case for printing is to print a summary table, which is well over a 100 lines long and cannot fit on a single page (it's taking about 4 pages currently).
I'd like the table headers to appear on every page. Is it possible, perhaps with something in 'customize'[2]?
The reason I'm pessimistic is because I think what the buttons plugin does is re-generate the table in HTML, and printing is handled by the browser, hence the plugin cannot tell what is in each page.
If my reasoning is correct (and there is no way to achieve the above), is there a way to print a table header every X rows instead? I think this should be possible.
If there's an alternative way to do this (say, perhaps using PDF export) I'm open to suggestions as well.
[1] - https://datatables.net/reference/button/print
[2] - https://datatables.net/extensions/buttons/examples/print/customisation.html
Answers
That's really a browser function rather than an aspect that DataTables / Buttons will cover. For example DataTables doesn't know what size of paper you are going to print on, therefore it doesn't know how large it would be.
I had thought that browser's would typically regenerate the
thead
when a table spans multiple pages - but perhaps that is no longer the case (or never was - my memory might be faulty!).Allan
I was afraid of that. Wonder whether it differs from browser to browser (as seems likely). Thanks
EDIT: You're right, it works fine on Firefox. Now to track down whether I can convince my users not to use Chrome (as seems likely based on [1]). Or perhaps I'll need to implement some flying saucer stuff...
[1] - http://stackoverflow.com/questions/274149/css-repeat-table-headers-in-print-mode