1

I'm implementing a simple Cancel button to cancel current form and navigate back to another route, but I want to show a confirmation message in case any field was changed from initial values.

Does anyone know if Model or JSONModel supports such feature in built-in or I have to implement it by my own?

It's not a hard job, but as this is a common need, I'm trying to reuse existing solution instead of writing it by myself.

agilejoshua
  • 2,848
  • 1
  • 21
  • 30
Marinho Brandão
  • 637
  • 1
  • 9
  • 30

1 Answers1

1

Probably these two API models will be helpful if you have an ODataModel:

hasPendingChanges(): boolean

Checks if there exist pending changes in the model created by the setProperty method.

To determine whether there are any changes to the model.

resetChanges(fnSuccess?, fnError?)

Resets the collected changes by the setProperty method and reloads the data from the server.

To undo the pending changes.

Both methods only work (as can be seen in the docs) if you changed the model via setProperty().


Concerning a JSONModel, there is no built-in functionality that I know of. But someone asked a similar question about tracking changes in a JSONModel which might be helpful: highlight a changed property on model load

Community
  • 1
  • 1
Marc
  • 6,051
  • 5
  • 26
  • 56