Multiple changes on 1 row will fire multiple update requests in parallel

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?

I reported the same issue over three weeks ago and I am waiting for response yet.

This problem appeared in the last version 7.3.0, in 7.2.5 it worked fine.

The problem was confirmed. We’ll try to fix it in the future updates.
Thank you for your report.

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”.

@sematik

After the update there are still some issues. This issue was different from the one reported by " Przemyslaw_Niedziela"

  1. If we do more than 2 updates, update 2 and the next will be sent in parallel.
  2. 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.
  3. 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.

@sematik

Thanks for the update most of the problems are solved.
There is one problem left
Steps to reproduce

  1. Add a row
  2. Update the new row
  3. Save the data

OR

  1. update a row
  2. remove the same row
  3. 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”)

1 Like

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.