Inline edit javascript dataTable without AJAX backend datasource
Inline edit javascript dataTable without AJAX backend datasource
I have a dataTable with javascript datasource and a dataEditor (whith inline edit enabled) which is bound to the dataTable.
When editing data I want the changes only to be reflected in the DOM, not in any AJAX backend datasource and not in localstorage.
How can I simply shortcut the ajax: parameter function in the Editor initialization?
I already tried to following approach but unfortunately it does not work correctly. Although changes are saved in the DOM, selecting a changed record again for inline editing shows the wrong record's data in the inline edit field.
var output = { data: [] };
if ( d.action === 'create' ) {
$.each( d.data, function (key, value) {
var rec = {};
rec[key] = value;
output.data.push( rec );
} );
}
else if ( d.action === 'edit' ) {
$.each( d.data, function (key, value) {
var currentRow = $("#tableName").dataTable().fnGetData(d);
currentRow.id = key;
$.extend(currentRow, value);
output.data.push(currentRow);
});
}
successCallback(output);
Have I missed something?
Thanks for your help,
Denis
This question has an accepted answers - jump to answer
Answers
Just tried with regular edit - same result.
It seems as if the dataTable is updated correctly with the changed values but when selecting a record and hitting edit the wrong record is pulled into the edit field,
Finally got it working (code designed for single row edit only):
@admin: please kindly mark last reply as solution. Unfortunately I have no clue how I do this for my own reply. Thanks.
Hi Denis,
Good to hear you got this working in the end :-)
Allan