Javascript 在jquery datatable中单击in按钮时,两个页脚未以pdf和excel格式打印
Actaullay我有按钮可以保存为pdf和excel格式。我有两个来自json的页脚,分别为“总计”和“百分比”。当我单击按钮时,只有“总计页脚”出现,但pdf和excel文件中没有“百分比”行。我需要同时显示页脚,但它没有出现Javascript 在jquery datatable中单击in按钮时,两个页脚未以pdf和excel格式打印,javascript,jquery,datatables,Javascript,Jquery,Datatables,Actaullay我有按钮可以保存为pdf和excel格式。我有两个来自json的页脚,分别为“总计”和“百分比”。当我单击按钮时,只有“总计页脚”出现,但pdf和excel文件中没有“百分比”行。我需要同时显示页脚,但它没有出现 <table id="report46Table" class="display responsive nowrap" style="width: 100%"> <thead>
<table id="report46Table" class="display responsive nowrap" style="width: 100%">
<thead>
<tr>
<th>Disturbance</th>
<th>Zero</th>
<th>Minor</th>
<th>Medium</th>
<th>Major</th>
<th>Total</th>
<th>Occurance</th>
</tr>
</thead>
<tfoot>
<tr id="fTotal">
<th>Total</th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
<tr id="fPercentage">
<th>Total</th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</tfoot>
</table>
骚乱
零
少数的
中等
专业
全部的
发生
全部的
全部的
加载数据表的脚本是:
<script>
$(document).ready(function() {
var report46Data = [];
var report46Footer = null;
var report46Table = $('#report46Table').DataTable({
data : report46Data,
dom: 'Bfrtip',
buttons: [
'copy',
{
extend: 'excel',
footer: true,
text : 'Export to Excel',
messageTop: 'Records of forest disturbances in the forest',
filename: function(){
return 'report46';
},
},
{
extend: 'pdfHtml5',
footer: true,
//orientation : 'landscape',
pageSize: 'TABLOID',
text : 'Export to Pdf',
messageTop: 'Records of forest disturbances in the forest',
title: '',
filename: function(){
return 'report46';
},
},
],
ordering: false,
"paging" :false,
columns : [ {
"data" : "disturbanceName"
}, {
"data" : "iZero"
}, {
"data" : "iMinor"
}, {
"data" : "iMedium"
} ,{
"data" : "iMajor"
},{
"data" : "total"
},{
"data" : "occurance"
}],
"footerCallback" : function(row, data, start, end, display) {
var api = this.api();
if (report46Footer) {
$($("#fTotal")[0].cells[0]).html(report46Footer[0].disturbance);
$($("#fTotal")[0].cells[1]).html(report46Footer[0].iZero);
$($("#fTotal")[0].cells[2]).html(report46Footer[0].iMinor);
$($("#fTotal")[0].cells[3]).html(report46Footer[0].iMedium);
$($("#fTotal")[0].cells[4]).html(report46Footer[0].iMajor);
$($("#fTotal")[0].cells[5]).html(report46Footer[0].total);
$($("#fTotal")[0].cells[6]).html("");
$($("#fPercentage")[0].cells[0]).html(report46Footer[1].disturbance);
$($("#fPercentage")[0].cells[1]).html(report46Footer[1].iZero);
$($("#fPercentage")[0].cells[2]).html(report46Footer[1].iMinor);
$($("#fPercentage")[0].cells[3]).html(report46Footer[1].iMedium);
$($("#fPercentage")[0].cells[4]).html(report46Footer[1].iMajor);
$($("#fPercentage")[0].cells[5]).html(report46Footer[1].total);
$($("#fPercentage")[0].cells[6]).html("");
}
}
});
$.ajax({
url : A_PAGE_CONTEXT_PATH + "/api/report46/all",
method : "GET",
dataType : "json",
success : function(response) {
report46Data = response.dataList;
report46Footer = response.footer;
report46Table.rows.add(report46Data).draw();
}
});
});
</script>
$(文档).ready(函数(){
var report46Data=[];
var report46Footer=null;
var report46Table=$(“#report46Table”).DataTable({
数据:report46Data,
dom:'Bfrtip',
按钮:[
“复制”,
{
扩展:“excel”,
页脚:是的,
文本:“导出到Excel”,
messageTop:“森林中的森林干扰记录”,
文件名:函数(){
返回“报告46”;
},
},
{
扩展:“pdfHtml5”,
页脚:是的,
//定位:'景观',
页面大小:“小报”,
文本:“导出为Pdf”,
messageTop:“森林中的森林干扰记录”,
标题:“”,
文件名:函数(){
返回“报告46”;
},
},
],
订购:错,
“分页”:false,
列:[{
“数据”:“干扰名称”
}, {
“数据”:“iZero”
}, {
“数据”:“iMinor”
}, {
“数据”:“iMedium”
} ,{
“数据”:“iMajor”
},{
“数据”:“总计”
},{
“数据”:“发生”
}],
“footerCallback”:函数(行、数据、开始、结束、显示){
var api=this.api();
如果(报告页脚){
$($(“#fTotal”)[0].cells[0]).html(report46Footer[0].html);
$($(“#fTotal”)[0].cells[1]).html(report46Footer[0].iZero);
$($(“#fTotal”)[0].cells[2]).html(report46Footer[0].iMinor);
$($(“#fTotal”)[0].cells[3]).html(report46Footer[0].iMedium);
$($(“#fTotal”)[0].cells[4]).html(report46Footer[0].iMajor);
$($(“#fTotal”)[0]。单元格[5]).html(report46Footer[0]。总计);
$($(“#fTotal”)[0].单元格[6]).html(“”);
$($(“#fPercentage”)[0].cells[0]).html(report46Footer[1].html);
$($(“#fPercentage”)[0].cells[1]).html(report46Footer[1].iZero);
$($(“#fPercentage”)[0].cells[2]).html(report46Footer[1].iMinor);
$($(“#fPercentage”)[0].cells[3]).html(report46Footer[1].iMedium);
$($(“#fPercentage”)[0].cells[4]).html(report46Footer[1].iMajor);
$($(“#fPercentage”)[0]。单元格[5]).html(report46Footer[1]。总计);
$($(“#fPercentage”)[0].单元格[6]).html(“”);
}
}
});
$.ajax({
url:A_PAGE_CONTEXT_PATH+“/api/report46/all”,
方法:“获取”,
数据类型:“json”,
成功:功能(响应){
report46Data=response.dataList;
report46Footer=response.footer;
report46Table.rows.add(report46Data.draw();
}
});
});
你能为你的代码创建小提琴吗?除了页脚部分的问题外,它工作正常。你可以看到上面的小代码。不,这个小代码不能解释问题。如果你能制作小提琴,我可以帮你修理。好的,我会制作小提琴并问你。谢谢合作