SAPUI5: How to Get the Data of an Item of a Detail View?

🏷️

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();
 
...

🙌 More Articles

🔥 The Complete SAP ERP Modules Overview Infographic in PDF Format (Free)

Plus, don't miss future infographics and free SAP tips and insights that are available only to newsletter subscribers. 

Leave a Comment

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed

Menu