Reputation: 3128
I use the DataTables Editor plugin (https://editor.datatables.net/) for editing a table with remote data (https://datatables.net/examples/data_sources/server_side.html) in inline mode (https://editor.datatables.net/examples/inline-editing/simple.html)
After some field is edited, submitted and a response from the editor's server handler is returned, the table always completely reloads sending an extra AJAX request to the server even though there's no need to do that since only one field in only one row was changed and all the data required to redraw the table row have already been received in the previous inline edit response.
So the question is whether it's possible to get rid of the extra AJAX call and redraw the edited row only, rather than completely refreshing the whole table.
The piece of code responsible for the reloading is:
// 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 );
...
}
)
...
}
Upvotes: 1
Views: 1580
Reputation: 1
try with stateSave: true https://datatables.net/reference/option/stateSave
$(document).ready(function() {
var table = $('#table_name').DataTable(
{
columnDefs: [{
orderable: false,
targets: [0, 1, 8, 9]
}],
,
stateSave: true,
"lengthMenu": [[10, 50, 100, 500, -1], [10, 50, 100, 500, "all"]]
}
)
});
Upvotes: 0
Reputation: 40
Here is an answer from Datatables Forum:
Yes, you can set the drawType option to none in the form-options object (e.g. the second, optional, parameter passed into inline(). That will stop DataTables from doing a redraw (in the case of server-side processing that involves the Ajax request). It does mean that any sorting or filtering changes caused by the change in data won't be immediately shown though.
Allan
Upvotes: 0