【发布时间】:2017-02-08 12:10:40
【问题描述】:
我使用 DataTables Editor 插件 (https://editor.datatables.net/) 在内联模式 (https://editor.datatables.net/examples/inline-editing/simple.html) 下编辑包含远程数据 (https://datatables.net/examples/data_sources/server_side.html) 的表
在编辑、提交某个字段并返回来自编辑器的服务器处理程序的响应后,表总是会完全重新加载,向服务器发送一个额外的 AJAX 请求,即使没有必要这样做,因为只有一行中只有一个字段已更改,并且在之前的内联编辑响应中已经收到了重绘表格行所需的所有数据。
所以问题是是否有可能摆脱额外的 AJAX 调用并仅重绘已编辑的行,而不是完全刷新整个表格。
负责重新加载的代码是:
// dataTables.editor.js
Editor.prototype._submit = function ( successCallback, errorCallback, formatdata, hide )
{
...
// Submit to the server (or whatever method is defined in the settings)
this._ajax(
submitParams,
function (json) {
...
// the following line forces the table to completely reload
that._dataSource( 'commit', action, modifier, json.data, store );
...
}
)
...
}
【问题讨论】:
标签: datatables datatables-1.10 jquery-datatables-editor