1
votes

I am working on a master/detail SAPUI5 example with ODataModel. Every selection at the master list is updating the binding path per ID to the details view. The user of my app should be able to alter the information appearing at the details page (aka change the model) per master list selection.

I wanted to have an alert when the user will switch from Master List item A to item B and the details of the Item A have been altered.

As such , I was planning using the "hasPendingChanges" method. While calling

this.getView().getBindingContext().getModel()

I realized that this method returns the same model. Having a JAVA background I was expecting to get the model of the current detail view. (the model! not the object...)

I would like to know if there is a way to check per master list selection if the current Details model has been changed.

I have found this question but in that case this guy is looking for the object , while in my case I am looking for the model so I can return the hasPendingChanges().

1

1 Answers

1
votes

You have to distinguish between the model and the application data. The model, in this case an ODataModel, exposes functionality to retrieve and modify application data via an OData service. The application data represent your entities as defined by your service's Entity Data Model.

Ideally all views in your application share the same model instance, that means:

this.getView().getModel()

should return the same instance in the master as well in the detail controller. The model contains the (partial) entity set shown in the master as well as the specific entities which have been loaded in the detail view by selecting an entry in the master list. If you change an entity in your detail view these changes are collected by the model.

Therefore it is save to call hasPendingChanges somewhere in your app to check if changes have been applied and not yet send to the OData service.