This is about how to get the model data of an item of a detail view in SAPUI5.
The model data for the item is bound to the detail view.
So you get the binding context of the detail view, and the item’s object model data from the binding context.
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:
Now, you want the data from that selected list item that’s shown in the detail view.
For example, you could reset the value of a form of the detail view.
You can easily get the context (model data) of the selected list item from the binding context of the detail view. The selected list item is bound to the detail view to take advantage of SAPUI5 binding (best practices) .
Here’s how to get the binding context of a view and therefore, all the data of the bound object:
// in your controller ... // get the view's binding context var oBindingContext = this.getView().getBindingContext(); // get the bound object var oObject = oBindingContext.getObject(); ...