Forum How do I...?

Multiple Table Headers spanning across pages

anthonyn
We have multiple table headers seperated by other data that we need to continue across pages. So for example:

---------------------------------
Header 1
---------------------------------
Content 1
---------------------------------
Header 2
---------------------------------
Content 2
---------------------------------

If it breaks across the page, it should look like:
Page 1:
---------------------------------
Header 1
---------------------------------
Content 1
---------------------------------
Header 2
---------------------------------
Content 2
---------------------------------

Page 2:
---------------------------------
Header 1
---------------------------------
Header 2
---------------------------------
Content 2 continued
---------------------------------

Is there any way to accomplish this?
mikeday
It is possible, but not obvious! :)

One way is to use table headers, that get repeated on each page. However, you can't introduce a new table header halfway through the table like you need for "Header 2". The trick is to use another table, nested inside the first table, like this:
<table>
<thead>
<tr><td>Header 1</td></tr>
</thead>
<tbody>
<tr><td>Content 1</td></tr>
<tr>
<td>
    <table>
    <thead>
    <tr><td>Header 2</td></tr>
    </thead>
    <tbody>
    <tr><td>Content 2</td></tr>
    </tbody>
    </table>
</td>
</tr>
</tbody>
</table>

You will need to set the style so that the inner table does not have any unwanted padding or borders to upset the layout. Then if "Content 2" is long enough to span more than one page, both table headers should be repeated at the start of the next page.

This method is a bit indirect, perhaps in the future we can introduce some new idiom to make this easier.
anthonyn
Thanks. I thought we had tried a nested table solution but maybe we didn't set something up correctly. I will try this approach again and see if we can get it to work. I'll post an example if I'm unable to.
anthonyn
Confirmed that this did work. Apparently we didn't test it correctly previously.

Thanks for the assistance.
rosebud
Hi!
I was wondering if this was still the suggested solution for this effect, or if there had been any changes with more recently released version?
Thank you!
mikeday
I think nested tables is still the only way, if you need repeating table headers and you need to introduce new headers half way through the table.
rosebud
Awesome! Thank you!