Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grouping table rows and page breaks

Tags:

css

I have a relatively long table. Each record has six rows. So an item with an identifier of 16 has <tr-16-1><tr-16-2>.....<tr-16-6>, identifier 25 would be <tr-25-1><tr-25-2>.....<tr-25-6>, etc.

I would like the page breaks to not split any grouping of the six rows. So if <tr-25-6> would continue on a new page, I would like all <tr-25's> to break with it.

I can easily attach a class to all six rows if that would help. Can anyone please point me in the right direction on how to do this? Thanks so much for your help.

like image 694
M Becker Avatar asked May 15 '12 11:05

M Becker


People also ask

Can you insert a page break in a table?

From the Table Properties dialog box, select the Row tab; Select the option 'Allow Row to break across pages' Click OK.

How do I split a page in a table?

Put your cursor where you want one page to end and the next to begin. Go to Insert > Page Break.


2 Answers

A possibility is grouping all the rows that are referring to the same record inside a single tbody, so you have more tbody each one containing 6 rows (it's perfectly fine and seems to be logical as an atomic group), then add this rule for media print

@media print {
    tbody {
        page-break-inside: avoid;
    }
}

In this way a page break inside a tbody will be avoided.
Unfortunately page-break-inside is supported on every modern browser except Firefox (Bug #132035)

like image 55
Fabrizio Calderan Avatar answered Oct 05 '22 12:10

Fabrizio Calderan


I would give this a shot:

@media print {
    tr, td, th { page-break-inside:avoid }
}
like image 40
lautomator Avatar answered Oct 05 '22 14:10

lautomator