我试图使用这些方法:
我的TypeScript代码:
var dataTableOptions = {
serverSide: true,
ordering: true,
searching: true,
columns: [
{ "data": "id" },
{ "data": "workflowId" },
{ "data": "discovery" },
{ "data": "title" },
{ "data": "createdBy" },
{ "data": "createDate" },
{ "data": "status" }
],
ajax: (data, callback, settings) => {
// server side service call
},
dom: 'rtiS',
scrollY: 400,
scroller: {
rowHeight: 35,
loadingIndicator: true
},
initComplete: function () {
forceRefresh = _.throttle(() => {
//this.api().ajax.reload(false);
this._fnDraw();
}, 1000);
setInterval(() => {
forceRefresh();
}, 5000);
}
}

答案 0 :(得分:1)
在ajax调用之前和表刷新(scrollTop
之后)再次分配它时,我没有找到任何其他方式作为滚动条的api().ajax.reload
。这对我有用。
答案 1 :(得分:0)
Datatable在服务器端操作时自动刷新(使用更新的数据),无需强制刷新。
$(document).ready(function() {
var dataTableOptions = {
serverSide: true,
ordering: true,
searching: true,
columns: [
{ "data": "id" },
{ "data": "workflowId" },
{ "data": "discovery" },
{ "data": "title" },
{ "data": "createdBy" },
{ "data": "createDate" },
{ "data": "status" }
],
ajax: (data, callback, settings) => {
// server side service call
},
dom: "frtiS",
scrollY: 400,
deferRender: true,
scroller: {
rowHeight: 35,
loadingIndicator: true
}
}
可以找到实时示例here