Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 我想在打印时隐藏数据表excel按钮_Javascript_Php_Jquery_Codeigniter_Media Queries - Fatal编程技术网

Javascript 我想在打印时隐藏数据表excel按钮

Javascript 我想在打印时隐藏数据表excel按钮,javascript,php,jquery,codeigniter,media-queries,Javascript,Php,Jquery,Codeigniter,Media Queries,我想在打印页面中隐藏excel数据表按钮 <style type="text/css" media="screen"> @media print { .buttons-excel { display: none; } } </style> <section class="content"> <div cl

我想在打印页面中隐藏
excel
数据表按钮

  <style type="text/css" media="screen"> 
       @media print {
             .buttons-excel {
                display: none;
            }
          }
      </style>

<section class="content">
        <div class="row">
         <div class="table-responsive">
           <table id="loading_sheet_table" class="table table-bordered  table-sm" style=" overflow: auto;">
          </table>
       </div>
     </div>
    </section>


<script>
   $(document).ready(function() {
  $('#loading_sheet_table').DataTable( {
    "paging": false,
      dom: 'Bfrtip',
      buttons: [
          'excel'
      ]
  } );
} );  

   function printContent(e1) {
   event.preventDefault();
        var allVals = [];
      $('input[name=selectedrecord]:not(:checked').each(function() {
         allVals.push($(this).val());
         });
           allVals.forEach(function(i){
          $('tr').each(function(){
          $(this).find('td, th').eq(i-1).css({
                     display:'none'
         });
      });
    });

    $('#print').css('visibility', 'hidden'); //hiding print button on print page
    $('input[name=selectedrecord]').css('visibility', 'hidden'); //hiding Check box on print page
    var restorepage     = document.innterHTML;
    var printContent    = document.getElementById(e1).innterHTML;
    document.innterHTML = printContent;
    window.print();
    document.location.href = "<?php echo base_url(); ?>"; 
    location.href="<?php echo base_url(); ?>booking/report/loading_sheet/LoadingSheetController/loadingSheetPage", 'refresh';
     }
</script>

@媒体印刷品{
.按钮excel{
显示:无;
}
}
$(文档).ready(函数(){
$('#加载_表')。数据表({
“分页”:false,
dom:'Bfrtip',
按钮:[
“卓越”
]
} );
} );  
函数printContent(e1){
event.preventDefault();
var-allVals=[];
$('input[name=selectedrecord]:未(:选中')。每个(函数(){
allVals.push($(this.val());
});
allVals.forEach(函数(i){
$('tr')。每个(函数(){
$(this.find('td,th').eq(i-1).css({
显示:“无”
});
});
});
$('#print').css('visibility','hidden');//在打印页面上隐藏打印按钮
$('input[name=selectedrecord]')。css('visibility','hidden');//在打印页上隐藏复选框
var restorepage=document.innterHTML;
var printContent=document.getElementById(e1).innterHTML;
document.innterHTML=打印内容;
window.print();
document.location.href=“”;
location.href=“预订/报告/装载工作表/装载工作表控制器/装载工作表页”,“刷新”;
}

我使用@media Print作为隐藏按钮,但它不起作用。

删除或修改媒体属性

请试试这个。 我认为您只需要使用Datatable打印选项

<section class="content">
    <div class="row">
     <div class="table-responsive">
       <table id="loading_sheet_table" class="table table-bordered  table-sm" style=" overflow: auto;">
      </table>
   </div>
 </div>
</section>


<script>
   $(document).ready(function() {
  $('#loading_sheet_table').DataTable( {
    "paging": false,
      dom: 'Bfrtip',
      buttons: [
          'excel',
          'print'
      ]
  } );
} );  

$(文档).ready(函数(){
$('#加载_表')。数据表({
“分页”:false,
dom:'Bfrtip',
按钮:[
“excel”,
“打印”
]
} );
} );  

希望它能解决您的问题。

如果您的问题是关于带有类
按钮excel
的按钮,您应该向我们展示这些按钮。@MrLister
按钮可能重复:['excel']
这个excel按钮我想隐藏在打印页是的,而使用
media=“print”
,您将不需要@media查询。