我正在使用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文件源? –