Printing Tables with HTML

Printing Tables with HTML

jmerrikinjmerrikin Posts: 1Questions: 0Answers: 0
edited July 2009 in General
Hi Allan,

Thanks for your awesome contributions toward making coding for the web a better place!

I am using DataTables on my site and it is working out perfectly, with plug-ins and all. My one challenge is that when a page is printed, I need to turn pagination and print ALL rows as it would appear on the page without any pagination. I am trying to find a way to do this:

"bPrinting": true

then, when initialized, I would use:

"bPrinting": [[# of records to print],[all]]

something that would allow ALL records to be printed ONLY when the print function is invoked. Wondering if there would be a way to use @media=print to control this in my style sheet or if there is a way to extend the API to do it.

Thanks again Allan. Dynamite work!

Best Regards,
Jim Merrikin
Senior UI Developer
Mercer Outsourcing

Replies

  • allanallan Posts: 61,451Questions: 1Answers: 10,055 Site admin
    Hi Jim,

    Interesting question you pose! I don't think that there is actually a way to do exactly what you are looking for, unless there is a way to hijack the browsers print option (is there a 'print' event listener?). The reason for this is in how DataTables hides the rows - it removes them from the DOM (storing them in cache for later use).

    What you might be interested in doing is making use of TableTools (not sure if you have seen this, or if it is what you are looking for or not) which has a 'print' button and when selected it will show all records (removing other bits an bobs from the window - until you press esc): http://datatables.net/1.5-beta/extras/TableTools/ .

    Thanks for your kind words - great to know the work here is useful!

    Allan
This discussion has been closed.