【问题标题】:jQuery DataTables Editor: avoid table reloading after an inline editjQuery DataTables Editor:避免内联编辑后重新加载表
【发布时间】: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


    【解决方案1】:

    这是来自 Datatables 论坛的answer

    是的,您可以在 form-options 对象中将 drawType 选项设置为 none(例如,传递给 inline() 的第二个可选参数。这将阻止 DataTables 进行重绘(在服务器端处理的情况下)这涉及到 Ajax 请求)。这确实意味着任何由数据更改引起的排序或过滤更改都不会立即显示。
    艾伦

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-03-13
      • 1970-01-01
      • 2014-05-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多