How to Get the Context of a Selected Item in a Detail View in SAP UI5?

UI5

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.

SAP UI5 master-detail application.
SAP UI5 master-detail view application.

Now you would like to get the data from the model of the selected item that is displayed in the detail view. For example, to validate the data of an edit form for the selected item against the current data of the selected item in the model to check if any data has been changed before saving.

You can easily get the context of the selected item of the detail view through the binding context of the view. The binding context has a method called getObject() that gets you the data of the detail view’s and thus the in the master view selected item.

// in your detail view's controller
...

// get the detail view's binding context
var oBindingContext = this.getView().getBindingContext();

// get the detail view's and thus
// in the master view selected item
var oSelectedItemData = oBindingContext.getObject();

...
No Comments
Get Dose for Excel
Dose for Excel screenshot.

Dose for Excel adds 100+ advanced functions and features for Microsoft Excel.

For example, you can:

  • Export sheets quickly
  • Merge cells or rows or columns without losing data
  • Comments assistant
  • Count cells by color
  • Advanced built-in formulas
  • Advanced built-in functions
  • Auto backup your workbooks easily
  • Lots more

Check it out here!

Get A COMPLETE SAP Modules Overview infographic (free)

Plus, receive for free SAP tips & insights and all future infographics that are only shared with the private newsletter subscribers. 

Complete SAP modules/components overview infographic.
Categories
Latest Poll
Essential Ressources

Leave a Reply

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.

Menu