开发者

printing table data in multiple pages

printing table data in multiple pages

How do i print the above table data in two pages based on group types seperately? Can this be achieved with window.print and some css and javascript tweaks?

Any idea/suggestion 开发者_如何学JAVAare welcome.


So, when the table switches from a group of "Teddy Bear" to "Baby Bear" you want this on a new page?

If so, then structure the table with separate <thead> and <tbody> sections, like so:

<table>
    <thead>
        <tr class="pageBreak">
            <th>Child</th>
            <th>Group</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>Alberto</td>
            <td>Teddy Bear</td>
        </tr>
        <tr>
            <td>Guadalupe</td>
            <td>Teddy Bear</td>
        </tr>
    </tbody>
    <tbody>
        <tr>
            <td>Carlos</td>
            <td>Baby Bear</td>
        </tr>
        <tr>
            <td>Oswaldo</td>
            <td>Baby Bear</td>
        </tr>
    </tbody>
</table>

Notice that different groups are in different <tbody>s.

Then you can use CSS like:

tbody {page-break-after:always;}

And the groups will print on separate pages, plus in most browsers, the headers will be repeated.

Print or print preview this example at jsBin.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜