allow printing complex header with rowspan and colspan
This pull request handle table with complex header that have rowspan and colspan. I'm using table API to get the table header, then create new element on the fly, set the colspan and rowspan same as the header in datatable, then use this for printing.
My first attempt is to clone the header and remove the attributes except colspan and rowspan. But I think, creating completely new th and only set colspan and rowspan from original datatables will be better, because it could be a lot of attributes that can be set by datatables in the future. Creating new element will make sure the th for printing only have colspan and rowspan attributes.
Demo: Existing print without complex header support https://jsfiddle.net/donnykurnia/qyp93yhc/
Print with complex header support https://jsfiddle.net/donnykurnia/bw0r56a2/2/
Related discussion:
- https://datatables.net/forums/discussion/29745/multiple-row-headers-export-in-pdf-excel-or-print#latest
- https://datatables.net/forums/discussion/36666/print-two-headers#latest
- https://github.com/DataTables/Buttons/issues/60
I acknowledge that my contribution is offered under and will be made available under the project's existing license (MIT).
Hi @DataTables, is there any ETA for this pull request? No pressure, just curious! And btw thanks for creating (and maintaining) this excellent utility, it is simply spectacular.
Thanks for your kind words. I'm sorry I've not commented here before.
Currently my plan is to implement a more advanced header / footer API in DataTables core, thus allowing the extensions to gain support automatically without needing their own special code. I've not got far down that track yet due to working on other parts of DataTables, but if that is successful, likely this PR wouldn't be merged in. I'm hesitant to pull something in to then replace it since it is only supported in parts (in this case printing).
Makes perfect sense to me, thanks for the quick response!
@DataTables any resolution on printing group columns? Thanks much from a happy supporter!
Not yet, sorry. I've done some work in a DT2 branch on the foundations of what will be required, but haven't yet had a chance to look at how it would integrate with Buttons.
This has finally been done and will ship in Buttons 3 alongside DataTables 2.