我正在使用jQuery DataTables 1.10和我所有的代码工作正常。要添加导出功能,请参阅this链接。我已添加所有文件说什么导出按钮没有出现在Datatable
//code.jquery.com/jquery-1.11.3.min.js
https://cdn.datatables.net/1.10.9/js/jquery.dataTables.min.js
https://cdn.datatables.net/buttons/1.0.3/js/dataTables.buttons.min.js
//cdnjs.cloudflare.com/ajax/libs/jszip/2.5.0/jszip.min.js
//cdn.rawgit.com/bpampuch/pdfmake/0.1.18/build/pdfmake.min.js
//cdn.rawgit.com/bpampuch/pdfmake/0.1.18/build/vfs_fonts.js
//cdn.datatables.net/buttons/1.0.3/js/buttons.html5.min.js
//cdn.datatables.net/1.10.9/css/jquery.dataTables.min.css
//cdn.datatables.net/buttons/1.0.3/css/buttons.dataTables.min.css
我已经下载这些文件并存储在本地。所以我的最终代码是这样的:
table = $(".jqueryDataTable").DataTable({
"initComplete": function(oSettings, json) {
alert('DataTables has finished its initialisation in table.');
this.fnHideEmptyColumns(this);
$('#lblReportHeader').html(reportHeader);
$('#lblFromDate').html(fromDateHeader);
$('#lblToDate').html(fromToHeader);
$('#tblReportHeader').show();
},
"searching": false,
"retrieve": true,
"destroy": true,
"ajax": "./getReportDetails",
"jQueryUI": true,
"dom": 'r<"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"},
{ "mData": "fromAccount", "sTitle": "fromAccount"}
]
});
但它没有显示我的用户界面上的任何导出按钮。
什么是错在我的代码?
工程正常** [这里](https://jsfiddle.net/Guruprasad_Rao/ym4wyc3s/)** ..我认为,因为您已经将其复制到本地并给了本地引用一些乱七八糟的东西。尝试给'cdn'文件参考本身.. –
我认为我有我的dom问题,你能纠正它吗?就像通过添加按钮参数一样? –
这是添加按钮的新版本,所以很抱歉地说,因为我对此没有太多的想法..并且您还有一些ajax格式来加载数据..所有这些都可能是问题的一部分。你有没有尝试给CDN文件源? –