doumei1926 2019-01-28 16:30
浏览 92

分页表 - 在一组行或每个tbody之后

I'm trying to have WKHTMLTOPDF only break a table after each tbody if necessary, never within a tbody, with each record having a tbody. I have also attempted to do this with one large tbody and somehow grouping the rows. Here is my current table code:

 <table class="table" style="table-layout:fixed;" width="100%">
                        <thead>
                            <tr>
                               <td width="5%" class="mainheader">#</td>
                               <td width="19%" class="mainheader">TASK NAME</td>
                               <td width="57%" colspan="3" class="mainheader">HAZARDS & CONTROLS</td>
                               <td width="19%" class="mainheader">RISK ANALYSIS</td>
                            </tr>
                        </thead>
                        @foreach($tasks as $task)

                            @php

                                $TaskDate = \Carbon\Carbon::parse($task->Date)->format('Y-m-d');
                                $riskbefore = $task->Severity * $task->Probability;
                                $riskafter = $riskbefore - $task->Effectiveness;
                                if($riskafter == 0)
                                {
                                    $riskafter = 1;
                                }

                            @endphp
                            <tbody>
                                <tr>
                                        <td class="darkgray bigboldtext doublebottom" rowspan="3"><strong>{{ $task->TaskOrder }}</strong></td>
                                        <td class="lightgray lfttext thickwhite" rowspan="2">{{ $task->Name }}</td>
                                        <td class="lightgray smalllfttext thickwhite" colspan="3"><strong>Hazards:</strong>&nbsp;{{ $task->hazards }}</td>
                                        <td class="darkgray thickwhite">
                                            <text class="bigboldtext">&nbsp;&nbsp;&nbsp;&nbsp;{{ $task->Severity }}&nbsp;&nbsp;&nbsp;&nbsp;x&nbsp;&nbsp;&nbsp;&nbsp;{{ $task->Probability }}&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;&nbsp;&nbsp;&nbsp;{{ $riskbefore }}</text></br>
                                            <text class="smalltext">&nbsp;&nbsp;&nbsp;SEVERITY&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PROBABILITY&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RISK BEFORE</text>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="lightgray smalllfttext thickwhite" colspan="3"><strong>Controls:</strong>&nbsp;{{ $task->controls }}</td>
                                        <td class="darkgray thickwhite">
                                            <text class="bigboldtext">&nbsp;&nbsp;&nbsp;&nbsp;{{ $riskbefore }}&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;&nbsp;&nbsp;{{ $task->Effectiveness }}&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;&nbsp;&nbsp;&nbsp;{{ $riskafter }}</text></br>
                                            <text class="smalltext">&nbsp;RISK BEFORE&nbsp;&nbsp;&nbsp;EFFECTIVENESS&nbsp;&nbsp;&nbsp;RESIDUAL RISK</text>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="darkgray smalltext doublebottomwhitesides">
                                                            {{ $TaskDate }}</br>
                                                            <strong>DATE CREATED</strong>
                                                        </td>
                                        <td class="darkgray smalltext doublebottomwhitesides">
                                                            {{ $task->SWP }}</br>
                                                            <strong>SAFE WORK PRACTICE</strong>
                                                        </td>
                                        <td class="darkgray smalltext doublebottomwhitesides">
                                                            {{ $task->SJP }}</br>
                                                            <strong>SAFE JOB PROCEDURE</strong>
                                                        </td>
                                        <td class="darkgray smalltext doublebottomwhitesides">
                                                            {{ $task->AF }}</br>
                                                            <strong>ADDITIONAL FORM(S)</strong>
                                                        </td>
                                        <td class="darkgray smalltext doublebottomwhitesides">
                                                            {{ $task->OM }}</br>
                                                            <strong>OPERATORS MANUAL</strong>
                                                        </td>
                                    </tr>
                            </tbody>
                        @endforeach
                    </table>

Here is the CSS that I am currently using:

tbody {
page-break-inside: avoid !important;
page-break-after:auto !important; 

}

It is absolutely critical that these 3 rows stay grouped on one page. Does anybody have any ideas?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Python turtle 画图
    • ¥15 关于大棚监测的pcb板设计
    • ¥15 stm32开发clion时遇到的编译问题
    • ¥15 lna设计 源简并电感型共源放大器
    • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
    • ¥15 Vue3地图和异步函数使用
    • ¥15 C++ yoloV5改写遇到的问题
    • ¥20 win11修改中文用户名路径
    • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
    • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计