Skip to Content

SAPUI5 - Control reference in formatter


I haven't asked a question here in like 5 years or so. So that means I'm really stuck...

In my SAPUI5 application, I cant to change the rotation of an icon depending on the value in the model. So I'm using a custom formatter, which takes in the model value. The custom formatter is in a separate formatter.js file. It's referenced in the view controller and it's being called correctly.

BUT! According to an old thread on StackOverflow, the "this"-reference should point to my uiElement. Which would be great, because that's exactly what I need to alter the rotation of the element. (thread: how-to-pass-control-reference-to-formatter-in-xmlview )

(there isn't a rotation property on an sap.ui.core.Icon, so please don't tell me that it's a bad idea to manipulate the uiControl from inside the formatter... )

Except that "this" apparently references my view controller, instead of my UI Element.


Please advise.


formatter-fun.png (62.4 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Dec 08, 2016 at 01:56 PM

    right, so here's the thing. it used to work. now it doesn't anymore.

    Due to no viable solution to change the inline css style of an element via the formatter, I just created an extension of the source object, added a rotation property, and hacked the renderer.

    works like a charm

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 08, 2016 at 01:59 PM

    you didn't follow it correctly

    just use the full name(path) of the formatter, don't put it in your controller

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      It doesn't,

      the latest libraries 1.40+ should have changed this behaviour;

      and this is quite a big issue of the framework; i need to change the color of some input texts based on the text itself, and those input fields are column elements of a table, so they do not have preassigned Ids

      the easy way would be a formatter function that add or remove some css class to the input control itself.

      and also every change / livechange event is triggered only if the change is performed by the user, so from the view to the model; but if the model is updated by a webservice or by calculation and the model propagates the update to the view than no change event is triggered.

      So my question is:
      Do you have any solution to perform actions on a control based on dynamic changes of a property of the control itself??