cancel
Showing results for 
Search instead for 
Did you mean: 

Timing issue when accesssing data that was just bound

Former Member
0 Kudos

Hi,

in my createContent method, I bind a OdataModel to a dropdown triggered by a button click.

Right after the control.bindItems() method, I cant access a model property via e.g. control.getBindingContext("myModel").getProperty("prop"); null / undefined is returned.

This can be managed with setting attachRequestCompleted on the model (in the controller "onInit"), and access the property within this method. Another way would be to work with the setTimeout(function(){}) function (in the view "createContent") to access the property.

I was wondering, if it is possible to attach a similiar event like attachRequestCompleted on a control within the createContent method, to indicate that the data was loaded?

The setTimeout(function(){}) function is not reliable enough.

Regards

Stefan

Accepted Solutions (1)

Accepted Solutions (1)

former_member293602
Active Participant
0 Kudos

Hi Stefan,

if it is really necessary to access a model property right after it has been read from the backend, I would recommend to stick to the attachRequestCompleted event. Depending on what you want to achieve,e.g. using the model property to display an icon , it might as well be possible to work with a formatter or make use of the type system.

Regards, Frank

Former Member
0 Kudos

Hi Frank,

thanks for your info, I think you are right.

What do mean with "make use of the type system". Can you explain that?

Regards

Stefan

former_member293602
Active Participant
0 Kudos

Hi Stefan,

if you would like to "format" the data you read from the backend, you can use the https://sapui5.netweaver.ondemand.com/sdk/#docs/guide/TypeSystem.html.

Regards, Frank

Former Member
0 Kudos

Thanks, that was helpful!

Answers (0)