When there are multiple edits on 1 row these will be tracked in the this._changes.order.
There will be a maxStack of 10 per item id. Then when de save is triggered all stored changes will be fired in parallel to the backend. The backend then will receive different versions of the same object, not knowing which is the latest version. This will cause issues.
Can the maxStack be set to 1 or be set through a setting/config option?
We have fixed your reported porblem with the newly added + edited row saving in the latest dhx.Suite update (v. 7.3.1).
Now a single “added” status will be sent instead of the “added” + “updated”.
After the update there are still some issues. This issue was different from the one reported by " Przemyslaw_Niedziela"
If we do more than 2 updates, update 2 and the next will be sent in parallel.
We see that the newly added “_getUniqueOrder” function will combine an “add and an update” and. But when the saved is done, the “update” will still persist in the “_changes.order” array.
In the “_getUniqueOrder” the state is checked against "“delete”, this must be “remove”
As we need a single update per row i overwrite the “_getUniqueOrder” as a workaround.
It also updates the “_changes.order” array.
/**
* this functions reduces the updates to one update per row. It also must update the "_changes.order" because
* otherwise the filtered items will still exist in the array after the update.
* This is an overwrite for the dhx Loader._getUniqueOrder
*/
const Loader_getUniqueOrder = function () {
return this._changes.order = this._changes.order.reduce(function (unique, el, orderInd) {
var ind = unique.findIndex(function (item) {
return item.id === el.id;
});
var involvedElem = ind > -1 ? unique[ind] : null;
if (involvedElem && involvedElem.saving === false) {
// Second update for a row
if (el.status === "update") {
// Set new data
involvedElem.obj = el.obj;
return unique;
}
if (el.status == 'add') {
// The first update must be a remove. This should result in an update
involvedElem.status = "update"
involvedElem.obj = el.obj;
return unique;
}
if (el.status === "remove") {
if (involvedElem.status === "add") {
// Do nothing
unique.splice(ind, 1);
return unique;
}
// Only keep delete
unique.splice(ind, 1);
unique.push(el);
return unique;
}
} else {
// first update for a row
unique.push(el);
}
return unique;
}, []);
};
My apologies for the delay with the reply.
We have fixed your reported problem in the latest (7.3.6) dhx.Suite update. Now the scenario works well and all the changes of a single dataCollection item are sending in a single request.
Please, try to update your dhx.Suite package to the latest one to get this fix.
Thank you for your report.
Thanks for the update most of the problems are solved.
There is one problem left
Steps to reproduce
Add a row
Update the new row
Save the data
OR
update a row
remove the same row
Save the data
After these steps the update is still in the this._changes.order array
After some investigation 1 found that the _removeFromOrder function is not working properly. The item is not removed from the array because the status of these update does not match (“add” vs “update” or “remove” vs “update”)
We have fixed the error occurring during the deleting the unsaved record. The fix is available since the latest dhx.Suite update (v7.3.11).
Please, try to update your dhx.Suite build to get that fix.
Thank you for your report.
Get a guaranteed answer from DHTMLX technical support team
under the most suitable support plan