Premium support for our pure JavaScript UI components


Post by jk@datapult.dk »

Hi,

Typically, when handling form submission the server can return validation errors and let the user change the input accordingly.

With the CrudManager as pr the documentation, an error response will get handled like this: "success is false indicating that an error has occurred. Not staged changes will be a part of next sync request." as pr https://bryntum.com/products/schedulerpro/docs/guide/Scheduler/data/crud_manager#error-handling

This can lead to the following issue:

  1. User submits something that causes a backend validation error response.
  2. User tries something different but since "not staged changes will be a part of next sync request" this will cause another error due to point 1.
  3. Only way out of this vicious circle is a page refresh.

I am thinking I should tap into onRequestFail to revert the change?

I tried acceptChanges() but this commits the changes to the frontend even though it was reject by the backend.

Should I use revertChanges()?, see https://www.bryntum.com/products/scheduler/docs/api/Scheduler/data/CrudManager#function-revertChanges

The description does not make it the obvious choice but the naming of the function does:

Reverts all changes in all stores and re-inserts any records that were removed locally. Any new uncommitted records will be removed.

How to deal with backend validation and CrudManagers?


Post by alex.l »

Hi jk@datapult.dk,

Yes, you are right.
Yes, revertChanges will revert all uncommited changes, include unsaved removed/added records.

All the best,
Alex


Post Reply