我在我的网站上使用数据表的唯一问题是,当我点击打印按钮时,它会显示带边框的空白表,请参阅附件https://i.stack.imgur.com/CsQ5F.png。当我刷新页面时,它显示数据。这是我的代码,请检查:
$('#data-table').DataTable({
dom: 'Bfrtip',
destroy: true,
searching: false,
info: false,
buttons: [{
text: 'Email',
className: 'btn-warning btn_send_email',
title: $('#dll_suser option:selected').text()
},
{
extend: 'excel',
className: 'btn-success',
title: $('#dll_suser option:selected').text()
},
{
extend: 'pdf',
className: 'btn-danger',
title: $('#dll_suser option:selected').text()
},
{
extend: 'csv',
className: 'btn-success',
title: $('#dll_suser option:selected').text()
},
{
extend: 'print',
className: 'btn-info print_btn',
text: 'Print',
autoPrint: true,
exportOptions: {
columns: [0, 1, 2, 3, 4, 5, 6]
},
customize: function(win) {
$(win.document.body).find('table').addClass('display').css({
'font-size': '12px'
});
$(win.document.body).find('th,td').each(function(index) {
$(this).css({
'text-align': 'center',
'padding': '5px 10px'
});
});
$(win.document.body).find('h1').css({
'text-align': 'center',
'font-size': '16px',
"float": 'left',
'width': '100%'
});
$(win.document.body).find('h1').text('Monthly Sling Check : ' + org_name);
$(win.document.body).find('h1').after('<div style="text-align:center; width:100%;float:left;"><div style="float:left;"> DOB : ' + $('#dll_suser option:selected').attr('dob') + '</div><div style="float:right;"> Room No. : ' + $('#dll_suser option:selected').attr('room_no') + '</div></div>');
$(win.document.body).find('h1').after('<div style=" width:100%; text-align:center;"><div style="float:left;">Service User(SU) : ' + $('#dll_suser option:selected').text() + '</div><div style="float:right">Date : ' + start_date + ' TO ' + end_date + '</div></div>');
$(win.document.body).css('height', 'auto');
}
}],
fixedHeader: {
header: !0,
headerOffset: $("#header").height()
},
responsive: true
});