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查询。