on 2019 Feb 03 10:08 PM
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you Mahesh. That worked !
Appreciate your response guys.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Have you tried binding the userid to the form control in the controller's onBeforeRendering function?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
63 | |
9 | |
8 | |
6 | |
6 | |
6 | |
6 | |
6 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.