This is about how to get the model data of an item of a detail view in SAPUI5.
The model data of the item is bound against the detail view.
Therefore, you get the binding context of the detail view and then the item object.
It’s time for the first step!
Get the Model Data of an Item of a Detail View
For example, you have a master-detail application.
When you click on a list item in the master view, then the detail view opens with the data of the selected item:
‘screenshot
Now you would like to get the data from the model of the selected list item that is displayed in the detail view.
For example, reset a value of an edit form of the detail form.
You can easily get the context (model data) of the selected list item through the binding context of the detail view—the list selected list item is bound against the detail view (best practices).
Here is how you get the binding context of a view and therefore, all the data of the object that is bound against the view:
// in your controller
...
// get the view's binding context
var oBindingContext = this.getView().getBindingContext();
// get the bound object
var oObject = oBindingContext.getObject();
...