[英]I want to hide data table excel button on print
我有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>
我使用@media Print作为隐藏按钮,但它不起作用。
删除或修改媒体属性
<style type="text/css" 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'
]
} );
} );
希望它能解决你的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.