dongzhi4239 2019-07-06 10:37
浏览 122

我的表中有大量列(42),如果我选中复选框,则只显示要在打印页面上显示的列数据

In my table there is large number of column(42) and unable to print all column on print so I give check box in table heading <th><input type="checkbox"/>LR No</th> and I want to show only selected check box data in my print page.

Following are some sample record of my table code in my controller

 <?php 

     $modelResult = $this->reportModel->bookingRegisterReportByLrno($data);

    ?>
      <table id="bilty_table" class="table table-bordered table-striped table-sm" style="display:block; overflow: auto; " width="100%">
                <thead>
                 <tr>
                  <th><input type="checkbox"/>LR No</th>
                  <th><input type="checkbox"/>Consignor Name</th>
                  <th><input type="checkbox"/>Consignor GSTIN</th>
                  <th><input type="checkbox"/>Consignee Name</th>
               </tr>
            </thead>
                <tbody>

                    <?php foreach($modelResult as $bilty){?>
                <tr>
                  <td><?php echo $bilty->lr_no;?></td>
                  <td><?php echo $bilty->consignor;?></td>
                  <td><?php echo $bilty->consignor_gst_no;?></td>
                  <td><?php echo $bilty->consignee;?></td>
                </tr>
                <?php }?>
                </tbody>
      </table>

This is my print page

<section class="content" style="overflow: auto;">
      <div class="row">
          <table id="booking_register_table" class="table table-striped" width="100%"> </table>
      </div> 
    </div>
  </section>


  <script>

        $(document).ready(function($) {

          var from_date_bk  = "<?php echo isset($_POST['from_date_bk'])? $_POST['from_date_bk'] :''; ?>";
          var to_date_bk    = "<?php echo isset($_POST['to_date_bk'])? $_POST['to_date_bk'] :''; ?>";
          var lr_from       = "<?php echo isset($_POST['lr_from'])? $_POST['lr_from'] : '';  ?>";
          var lr_to         = "<?php echo isset($_POST['lr_to'])? $_POST['lr_to'] : '';  ?>";
          var lr_pay_mode   = "<?php echo isset($_POST['lr_pay_mode'])? $_POST['lr_pay_mode'] : '';  ?>";
          var orderby       = "<?php echo isset($_POST['orderby'])? $_POST['orderby'] : '';  ?>";

          $.ajax({
               url :"<?php echo base_url(); ?>booking/report/booking_register/BookingRegisterController/bookingRegisterReport",
               type: 'POST', 
               async:false,              
               data: {
                from_date_bk:from_date_bk,
                to_date_bk:to_date_bk,
                lr_from:lr_from,
                lr_to:lr_to,
                lr_pay_mode:lr_pay_mode,
                orderby:orderby
               },
               dataType: "html",
               success: function(data){
                  console.log(data);
                  $('#booking_register_table').html(data);
               },
               error:function(data){
                console.log('error occured during fetch');

               }
           });


    $('#booking_register_table').DataTable( {
        dom: 'Bfrtip',
        "pageLength": 100,

        buttons: [
            {
                extend: 'print',className: "btn btn-primary",
                customize: function ( win ) {
                    $(win.document.body)
                        .css( 'font-size', '10pt' )
                        .prepend(
                            '<h2 align="center"><font color="#5CAAFF">Barque Trans And Logistics P.V.T.L.T.D</font></h2>'+
                      '<h3 align="center" ><font color="#5CAAFF">Safeguarding Valuables</font></h3>'+
                      '<hr style="height: 1px;">'+
                      '<h5 align="center"><strong>REPORT FOR BOOKING REGISTER</strong></h5>');

                    $(win.document.body).find( 'table' )
                        .addClass( 'compact' )
                        .css( 'font-size', 'inherit' );
                },
                 title: '',
                exportOptions: {
                    columns: ':visible'
                }
            },
            {
                extend: 'colvisGroup',
                text: 'Show all',
                show: ':hidden'
            },
            {
                extend: 'colvis',
                text: 'Select Columns',

            },
            {
                extend: 'colvisGroup',
                text: 'Office Use',
                show: [ 0,1,19,2,4,8,10,23,14,33,34,35,36,39 ],
                hide: [ 3,5,6,7,9,11,12,13,15,16,17,18,19,20,21,22,24,25,26,27,28,29,30,31,32 ]
            },

        ],
        columnDefs: [ {
            targets: -1,
            visible: false
        } ]
    } );
} );

</script>

How can I print record only selected columns

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
    • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
    • ¥60 pb数据库修改与连接
    • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
    • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
    • ¥20 神经网络Sequential name=sequential, built=False
    • ¥16 Qphython 用xlrd读取excel报错
    • ¥15 单片机学习顺序问题!!
    • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
    • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)