cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass context of oController into the formatter function?

0 Kudos

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

View Entire Topic
Former Member
0 Kudos


Hi Murthy,

Have you tried this.

new sap.m.Input('payOut', {

  value: "",

  formatter: [oController.formatPayOutAmount  ,oController]

});

Thank you.

Regards,

              Pruthvi.

0 Kudos

Hi Pruthvi,

This doesnt work, please read my quesion fully.

You can play around in the example I have created below.

JS Bin - Collaborative JavaScript Debugging</title> <link rel="alternate" type=&q...

Former Member
0 Kudos

Hi Chida,

          Found a fix,

JS Bin - Collaborative JavaScript Debugging</title> <link rel="alternate" type=&q...

This works fine.

Regards,

               Pruthvi.

0 Kudos

Hi Pruthvi,

formatter: jQuery.proxy(oController.formatHello,oController)  --> this is good. Thanks.

Regards,

Chidan

0 Kudos

Hi Pruthvi,

Althoug the question is answered, could you please extend your answer to cover below point.

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