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 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:

SAPUI5 Master Detail Application Detail View Screenshot.
[SAP]

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

🔥 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. 

📚 More Articles

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

🚀 Upgrade Your Work Experience With Altwork (Welcome to the Future)

altwork_picture_2

The Altwork Station redefines how people interact with their computers by allowing the computer screen and keyboard to physically conform to support the user’s body while working long hours on a computer.

Submission received, thank you!

Close Window