I have displayed a list of items (aggregation binding) and edit button by each item to edit the values of the items. Edit button opens a popup where I can change the value(s).
I am using Two-Way Binding and I call submitChanges() after editing the values in popup and pressing popup 'OK' button.
submitChanges has two callbacks - success and error. Now when an error comes from the backend (e.g. Another user is currently editing the item) I can handle and show the error message. And the data are not changed in the backend. However the model itself (in frontend) is changed despite the error.
Is this something which must be handled by OData service itself? Or should I do something in frontend? calling resetChanges() is not helpful - after submitChanges there are no changes to revert.
Any examples or best practices?
If submitChanges
is not successful and you get into error handler, the data stays in the “edited” form in front end (so you could try to submit again).
It’s up to your front end logic to decide what to do:
resetChanges
(there ARE !! changes after a non-successful submitChanges
) and to oModel.refresh
after that to reget a fresh copy from backend, so the user can start editing againAnd - of course you may offer the choice to the user - to reset everything and get a fresh copy from backend - or maybe a reset button in each row to be able to reset single items individually.