on 09-19-2016 4:23 PM
Hi there! I'm trying to capture the value of an input field in a Fiori view with no luck at all. I’ve created the input field as follows:
Input id="ZFINALPRICE" class="soc-table-label-elem-align" value="{path: 'soc_cart>CustomFinalPrice', formatter:'sap.ca.ui.model.format.AmountFormat.FormatAmountStandard'}" type="Number" valueLiveUpdate="true" enabled="true" editable="true"/
And I’m trying to capture its value this way:
var oVal = this.getView().byId("ZFINALPRICE");
var oVal = this.getView().byId("ZFINALPRICE").getValue();
Everything seems to be OK despite captured value is “”…empty. What am I doing wrong? Can anybody help me? Capture is attached....
Thanks in advance!
Hello,
I am not sure why your code is not working, might be "This" may be referring to some other object it depends from where you're calling the function.
just try this once
on init:
this._oPriceInput = this.byId("ZFINALPRICE");
in prepData() : this._oPriceInput.getValue()
But Recommended is:
if your model is having twoway binding mode, then you should use below code:
var oVal = this.getView().getModel("soc_cart").getProperty("/CustomFinalPrice");
Regards,
Akhilesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
check out
https://sapui5.netweaver.ondemand.com/#docs/guide/91f233476f4d1014b6dd926db0e91070.html
create a 2 way binding JSON model - using MVC and then you should be able to retrieve and set the model.
it is a better approach (best practices as well)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.