当数据表中没有可用数据并且单击generate pdf选项时,我收到此错误。我已经使用了pdfmake js。 所有其他选项都正常工作,如生成csv,excel等,但不是pdf生成函数。
这是我的数据表工作代码
$('#listTable').DataTable({
dom: 'Bfrtip',
buttons: [
'copy', 'csv', 'excel', {
extend: 'pdfHtml5',
orientation: 'landscape',
pageSize: 'LEGAL',
customize: function ( doc ) {
doc.content.splice( 1, 0, {
margin: [ 0, 0, 0, 12 ],
alignment: 'center',
});
}
},
{
extend: 'print',
}
],
'paging': true,
"pagingType": "full_numbers",
"lengthMenu": [10, 25, 50, 75, 100],
'autoWidth' : false,
'stateSave' : true,
scrollCollapse: true
});
答案 0 :(得分:1)
找到解决方案。在 dataTables.buttons.js 中将body行数组设置为空,以便在打印操作时不会考虑任何行。
var body = [ rows ];
var body = [];
有关详细信息,请访问此链接:https://github.com/DataTables/Buttons/commit/912d605b7f65e05f28444742c62447e9fd72a972