Monday, May 13, 2024
 Popular · Latest · Hot · Upcoming
32
rated 0 times [  35] [ 3]  / answers: 1 / hits: 30450  / 8 Years ago, mon, august 1, 2016, 12:00:00

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 >




  1. How to get the programatically values for inputAmount or lblCurrency?

  2. 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.


More From » html

 Answers
23

you 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.com/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}};

[#61185] Thursday, July 28, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
lailab

Total Points: 706
Total Questions: 102
Total Answers: 95

Location: Falkland Islands
Member since Mon, Jul 13, 2020
4 Years ago
;