I'm starting on OPENUI5/SAPUI5 and I was trying to access the data for the controls i've implemented. For example:
<Label text="Amount" />
<Input id="inputAmount" value="{Amount}" />
<Text id="lblCurrency" text="USD" >
- How to get the programatically values for inputAmount or lblCurrency?
- Initially i'm using a mockup-server, how to get access to the odata model programatically? I'm using:
console.log( this.getView().getModel().getJSON() );
I can't get the structure, but i had deployed the data on the objects and actually is showed on screen.
I'm starting on OPENUI5/SAPUI5 and I was trying to access the data for the controls i've implemented. For example:
<Label text="Amount" />
<Input id="inputAmount" value="{Amount}" />
<Text id="lblCurrency" text="USD" >
- How to get the programatically values for inputAmount or lblCurrency?
- Initially i'm using a mockup-server, how to get access to the odata model programatically? I'm using:
console.log( this.getView().getModel().getJSON() );
I can't get the structure, but i had deployed the data on the objects and actually is showed on screen.
Share Improve this question asked Aug 1, 2016 at 21:10 MarioMario 752 gold badges2 silver badges6 bronze badges1 Answer
Reset to default 2you can get the control by it's id and then access it's value so in your code:
Accessing the Text control in the controller
sap.ui.getCore().byId("lblCurrency").getText()
Accessing the Input value control in the controller
sap.ui.getCore().byId("inputAmount").getValue()
The code above show how to access to value in the standard way. If you will use binding (binding is when you have a model which updates your view and if it's 2-way binding also your view updates you model) then in order to access to value you need to access access the model and extract it from there
example of binding and how to use it can be found here:
https://help.sap./saphelp_uiaddon10/helpdata/en/91/f0f3cd6f4d1014b6dd926db0e91070/content.htm
Update
in order to get the data from the model you need to use the getProperty function under the model so your code should look some
oModel.getProperty("{PATH_TO_WHERE_THE_PROPERTY_IS_LOCATED",{OPTIONAL_CONTEXT}};