【发布时间】:2015-12-08 22:51:48
【问题描述】:
我在我的 jquery 数据表中使用 HTML5 导出按钮来导出表数据。按钮显示正确,但无法导出 pdf/excel 的数据,但复制按钮工作正常。 我的代码是:
table = $(".jqueryDataTable").DataTable( {
"searching": false,
"retrieve": true,
"destroy": true,
"ajax": "./getReportDetails",
"jQueryUI": true,
"dom": 'Bfr<"H"lf><"datatable-scroll"t><"F"ip>',
buttons: [
'copyHtml5',
'excelHtml5',
'csvHtml5',
'pdfHtml5'
],
"fnServerParams": function ( data ) {
newData=data;
newData.push( { "name": "reportType", "value": reportType }, { "name": "reportSubType", "value": reportSubType}, { "name": "fromDate", "value": fromDate}, { "name": "toDate", "value": toDate});
},
"columns": [
{ "mData": "username", "sTitle": "username"},
{ "mData": "transferType", "sTitle": "transferType"}
]
} );
我参考了here。我已经包含了所有必需的文件。
我的数据表也显示了正确的数据。
编辑:单击 excel 按钮时,我在文件 buttons.html5.min.js 中收到 javascript 异常 Uncaught TypeError: Cannot read property 'replace' of null,单击 pdf 按钮时出现异常
Uncaught TypeError: Cannot read property 'length' of null 在pdfmake.min.js。
我的代码有什么问题?
【问题讨论】:
-
你能在jsFiddle上创建一个例子来演示这个问题吗?
标签: javascript jquery html css datatables