cancel
Showing results for 
Search instead for 
Did you mean: 

SAPUI5 - oData Simple Form Binding

former_member403613
Discoverer
0 Kudos

Hi Experts,

I'm trying to retrieve an OData model from inside onInit function of controller in SAPUI5 to access a property into a local variable.

I need “UserID” to define the sPath("/UserSets('SHARM2')")in order to bind it to Simple Form control using the following statement.

this.getView().byId("SimpleForm").bindElement("/UserSets('SHARM2')")

It’s a simple UI5 Update data form for current user logged in. I have tried to use “oModel.read” and “oModel.attachrequestcompleted” but since data loading is asynchronous, “UserID” is not available for form binding.

Please help.

Accepted Solutions (1)

Accepted Solutions (1)

maheshpalavalli
Active Contributor
0 Kudos

Hi Yogesh Sharma

Yes oData V2 is asynchronous. So you need to read like below:

oModel.read("/EntitySetName('Key')",{
   success: function(mData){
        console.log(mData);
        // Here check the mData and below set the bind element
        this.getView().byId("SimpleForm").bindElement("/UserSets('SHARM2')")
      }.bind(this)
}); 

There are lot's of blogs & answers outthere which answers your query..

BR,

Mahesh

former_member811618
Discoverer
0 Kudos

Thanks a lot Mahesh Bhai.

Best Regards,

Answers (2)

Answers (2)

former_member403613
Discoverer

Thank you Mahesh. That worked !

Appreciate your response guys.

saurabh_vakil
Active Contributor
0 Kudos

Have you tried binding the userid to the form control in the controller's onBeforeRendering function?