Forum How do I...?

Table header and footer only once

mn4367
I'm sure this should be quite simple, but I could find any solution for this problem. I have a table with a thead and a table caption (below the table) and I'd like to have the following behaviour:

Case 1 (table fits on one page, no problem here):

Table header (<thead>)
--------------------
Table row
Table row
Table row
Table row
--------------------
Table caption (<caption>)


Case 2 (same as case 1 but with a very long table with one or more page
breaks in the table, or table doesn't fit on the curent page):


Table header
--------------------
Table row
Table row
...
-----------------------------------   <- page break
Table row
Table row
...
Table row
Table row
...
-----------------------------------   <- page break
Table row
Table row
--------------------
Table caption


So I've actually two questions

- How can I have a table header appear only at the beginning of the table, not on subsequent pages?
- How can I have a caption only at the end of the table, not repeated on subsequent pages?

I know that I could simulate this with divs for the table header and the caption together with a table that doesn't use thead and caption at all, but that violates the sematics of a table too much in my opinion.

And it wouldn't be easy since the HTML is generated by a Markdown processor.

Thanks!
mikeday
At the moment you need to use divs, as there is no CSS mechanism for controlling the repetition of table headers and footers.
mn4367
OK, thanks.

Isn't that a bit strange? I thought that this is a common use case. Any chance that this can be added to Prince with some prince-* properties?
mikeday
I think this is the first time it has come up, actually. We have had requests for changing the content of headers/footers on following pages.

I can add this to the roadmap, but we might not get to it for a while, as the roadmap is very long. :)
mn4367
Yes, I saw the roadmap... :-)

Not really a big problem for me, I think I can get around it with a DOM parser or some XSLT. But I think it would be worth putting it on the roadmap or even propose it for the CSS spec.

Thanks.
perry
Is this issue addressed yet? The header and footer for a table are repeating if the table spans to the next page
jamsheer
Is this issue addressed yet? The header and footer for a table are repeating if the table spans to the next page.

I need the <thead> on the top of the first page and <tfoot> on the bottom of the last page.
Is there any Prince property to achieve the same?
mikeday
How about applying "display: table-row-group" to the thead and tfoot so that they are treated similar to tbody and do not repeat?
jamsheer
I already applied the same ("display: table-row-group") in style. But in the HTML the "<tfoot>" is in between the "<thead>" and "<tbody>".

Changing the <tfoot> order is very complex in our HTML. Here I'm using radGrid and the issue with the radGrid footer.

Our current HTML order is like the below code.
<style type="text/css">
   thead{ display:table-row-group; }
   tfoot{ display:table-row-group; }
</style>
<table>
   <thead>
      Header
   </thead>
   <tfoot>
      Footer
   </tfoot>
   <tbody>
      Body Contents
   </tbody>
</table>


So in our pdf, the footer is coming in between the header and body. I attached a screenshot of the pdf view.
Is there any other solution for the same?
  1. Header and Footer.png33.0 kB

Edited by jamsheer

mikeday
You could use JavaScript to move the tfoot to the end of the table?