on 01-14-2015 10:00 AM
Hello Friends,
I have a scenario where I have to pass the context of oController into the formatter function as inside the formatter function I want to access function belonging to oController. Below is code sample:
new sap.m.Input('payOut', {
value: '',
fomratter: oController.formatPayOutAmount
})
Now inside fomatPayOutAmount() I want "this" to refer to oController.
Obvioulsy [fomratter: oController.formatPayOutAmount , oController] is not working.
Regards,
Chidan
I'm not sure what you're after...
if your sap.m.Input control is instantiated in the view, and you have specified the formatter to call a method in your controller, then inside that method "this" refers to your controller.
Unless you're calling "this" from within an inner function, but without seeing your formatter function I cannot tell if that's the case
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Robin,
Nopes I dont think it works as you said or I am getting something seriously wrong.
I have created an example below please have a look.
"this" will point the formatter function and not the oController.
Regards,
Chidan
Hi Robin,
Would you have an answer for this?
How to make sure formatter is called when the data is changed in the binded field. For now formatter is only called once during instantiation.
I tried to use model.refresh() and model.checkUpdate(), but model.refresh sets it to initail binded value and checkUpdate() is private method and if you see internally checkUpdate() also calls refresh()
Regards,
Chidan
Hi,
I'm not sure what you mean... if you update the model, then the formatter will just update accordingly
Check this little example http://jsbin.com/povoso/1/edit?html,js,output
Initially it shows an Input field with a value, and underneath it another Input field with a formatted value (based on the input of the field above)
If you now change the value in the first Input (and hit 'Tab' to update the model property), the second field will update just fine
If I understand you correctly, you want to manually change a value in an inputfield which also has a formatter assigned?
That is currently not possible. From the API docs:
Currently, calculated fields work only from model to view, read only, and the values can be accessed via a formatter function.
However, in theory you could create a new custom type which extends from SimpleType and have the formatter assigned there
User | Count |
---|---|
69 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.