0
到目前爲止,我已經完成了這項工作。完全裝載後,表格顯示完美。但是,當我加入t.ajax.reload()
,它顯示TypeError: t.ajax is undefined
爲什麼在DataTable()上調用ajax.reload()會返回undefined?
$.fn.dataTableExt.oApi.fnPagingInfo = function(oSettings)
{
return {
"iStart": oSettings._iDisplayStart,
"iEnd": oSettings.fnDisplayEnd(),
"iLength": oSettings._iDisplayLength,
"iTotal": oSettings.fnRecordsTotal(),
"iFilteredTotal": oSettings.fnRecordsDisplay(),
"iPage": Math.ceil(oSettings._iDisplayStart/oSettings._iDisplayLength),
"iTotalPages": Math.ceil(oSettings.fnRecordsDisplay()/oSettings._iDisplayLength)
};
};
var t = $("#mytable").dataTable({
initComplete: function() {
var api = this.api();
$('#mytable_filter input')
.off('.DT')
.on('keyup.DT', function(e) {
if (e.keyCode == 13) {
api.search(this.value).draw();
}
});
},
oLanguage: {
sProcessing: "loading..."
},
processing: true,
serverSide: true,
ajax: {"url": "data/json", "type": "POST"},
columns: [
{
"data": "id",
"orderable": false
},
{"data": "nama"},
{"data": "stok"},
{"data": "satuan"},
{
"data" : "action",
"orderable": false,
"className" : "text-center"
}
],
order: [[0, 'desc']],
rowCallback: function(row, data, iDisplayIndex) {
var info = this.fnPagingInfo();
var page = info.iPage;
var length = info.iLength;
var index = page * length + (iDisplayIndex + 1);
$('td:eq(0)', row).html(index);
}
});
setInterval(function() {
t.ajax.reload();
}, 3000);
任何建議將apreciated。提前致謝!
非常感謝你,它的工作原理.. – Ukasyah