javascript - 我想在打印时隐藏数据表 excel 按钮
问题描述
我有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">
推荐阅读
- node.js - node.js 没有从 m3u8 文件生成完整的 m3u8 剪辑
- node.js - 推送被拒绝的 Heroku Node.JS
- hive - date_add 用于 Hive 中的时间戳
- node.js - 将 React API 调用提取到 Express 后端服务器
- r - 从 Shiny App 保存用户生成的 ggplot
- php - 需要为 Analytics 和 Reporting API 设置凭据的详细信息
- list - 将带有标题的部分添加到具有可扩展行的 SwiftUI 列表
- google-kubernetes-engine - 如何在同一服务器 GKE 中运行相同部署的 2 个 Pod 时发出警报
- c++ - C++ 入门第 5 版:表示整数序列的位集
- javascript - 如何将 div 对齐?