duan20081202 2019-05-26 02:57
浏览 119

如何在新的分页符中重复表头

I have a dynamic table in my web page that sometimes contains lots of rows. I made the page-break after 22 rows. i need to repeat certain table (info table, see image) in a new page. how do i do that?

image https://i.ibb.co/LN8gVbD/Screen-Shot-2019-05-26-at-03-34-26.png

the other thing, I'm unable to get the page-break in Chrome. it's only working in Firefox, how to fix that in Chrome?

 <style type="text/css">
    #receipt-data { font-size: 12px; }
        @media print {
                tr.page-break{
                page-break-inside: avoid;;
                page-break-before:always; 
            }  
            @page {
              size:portrait;
                }
        }
    </style>

    <div id="receipt-data">
<table class="table hed">
<thead style="text-align:center;">
<tr style="text-align:center;">  
    <th colspan="1">Name</th>
<th colspan="2">{{$customer_data->name}}i</th>
<th colspan="1">Customer Tax No</th>
<th colspan="2">{{$customer_data->tax_no}}</th>
</tr>
</thead>
</table>

 <table class="table table-bordered" style="text-align:center;">
            <thead>
                <tr>
                    <th>S</th>
                    <th>Item Code</th>
                    <th>Description</th>
                    <th>Unit</th>
                    <th>Unit Price</th>
                    <th>Qty</th>
                    <th>Amount($)
                    </th>
                </tr>
            </thead>
            <tbody>

                @foreach($product_sale_data as $key=>$product_sale_data)
                @php
          $product_data = \App\Product::find($product_sale_data->product_id);
                    if($product_data->sale_unit_id)
      $unit = \App\Unit::find($product_data->sale_unit_id)->unit_name;
                    else
                        $unit = 'N/A';
                @endphp  
    <tr class =  @if  ( $key % 22 == 0 && $key ) "page-break"   @endif>
 <td>{{$key+1}}</td>
  <td>{{$product_data->code}}</td>
  <td>{{$product_data->name}}</td>
 <td>{{$unit}}</td>
<td>{{number_format($product_sale_data->total / $product_sale_data->qty, 2)}}</td>
                    <td>{{$product_sale_data->qty}}</td>
                    <td>{{number_format($product_sale_data->total, 2)}}</td>
                @endforeach
                 <br>
  • 写回答

1条回答 默认 最新

  • dsnhalq37505 2019-05-26 04:30
    关注

    NOTE: If $key value start with 0 then below <thead> is not need but if $key starts with 1 then below is needed for one time no need to loop in foreach

        <thead>
            <tr>
                <th>S</th>
                <th>Item Code</th>
                <th>Description</th>
                <th>Unit</th>
                <th>Unit Price</th>
                <th>Qty</th>
                <th>Amount($)
                </th>
            </tr>
        </thead>
        @foreach($product_sale_data as $key=>$product_sale_data)
            @if  ( $key % 22 == 0 && $key ) // so here every 22 rows after this will go
                <thead>
                    <tr>
                        <th>S</th>
                        <th>Item Code</th>
                        <th>Description</th>
                        <th>Unit</th>
                        <th>Unit Price</th>
                        <th>Qty</th>
                        <th>Amount($)
                        </th>
                    </tr>
                </thead>
            @endif
            <tbody> 
                @php
                $product_data = \App\Product::find($product_sale_data->product_id);
                    if($product_data->sale_unit_id)
    
                ...continue your code
    
    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?