Server side edit row on another page
Server side edit row on another page

Hello.
How can I edit row if table is server side but item on another page?
I have import via excel and I need to check if row existed and rewrite if user confirm rewriting. But we found a problem that if we use server side and item not on current page - backend has empty request (only action and no data).
Unfortunately I can't give access or link to webpage
How I made this check
1) Get all data via ajax request same from editor.
var params = table.ajax.params();
var newParams = $.extend(true, {}, params, {
draw: 1,
length: -1,
search: { value: "" },
searchBuilder: null,
start: 0
});
$.ajax ...
2) If primary keys already exist - add item to array ToUpdate and DT_RowId to array toUpdateRowIds, if not - ToCreate.
3) create new instance of editor with 2 buttons - Confirm update or Skip
var options = {
title: ImportUpdateTitle,
buttons: [
{
text: ImportUpdateButtonConfirm,
action: function (e, json, data, action) {
for (var i = 0; i < fields.length; i++) {
var field = editor.field(fields[i]); // From start I don't know columns, fields are dynamic
var fieldName = field.name();
for (var j = 0; j < toUpdate.length; j++) {
var value = toUpdate[j][fieldName] ? toUpdate[j][fieldName] : null
field.multiSet(toUpdateRowIds[j], value);
}
}
editor.one("postSubmit", function (e, json, data, action, xhr) {
if (toCreate.length > 0) {
createRecords(editorCreate);
}
else {
editor.close()
}
})
editor.submit(null, null, null, false);
}
},
{
text: resxTranslations.ImportUpdateButtonNotConfirm,
action: function (e, json, data, action) {
if (toCreate.length > 0) {
createRecords(editorCreate);
}
else {
editor.close()
}
}
}
],
message: message
} as IFormOptions;
editor.edit(toUpdateRowIds, options = options);
I found only one same problem from forum, but it was 2010 https://datatables.net//forums/discussion/2272 .
Copilot propose me add to this updated rows on table, but it not help ( I have an error Could not find an element with data-editor-id
or id
)
if (!table.row('#' + rowId).length) {
table.row.add(rowData).draw(false);
}
Second try was - set pageLength -1 and redraw, but I need to set drawCallback once. Maybe will be simple solution.
Thanks
Answers
P.S. Second solution is working, but it work fine and quick when I have 25 rows. But in some tables I have 30 000 rows, and then it will take time to redraw full table