-1

Can we update CSS depending on the model data?

Here I am trying to toggle between cursor: pointer; and cursor: default;.

<core:Icon id="Submit Button"
  size="2rem"
  src="sap-icon://appointment"
  press="onAppointmentIconClick"
  enabled="{
    path: 'data>/isFree',
    formatter: '.buttonFormat'
  }">
</core:Icon>
Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170
Kitty
  • 179
  • 6
  • 13
  • 29
  • Does this answer your question? [Binding in Control with "class" Attribute](https://stackoverflow.com/questions/42221962/binding-in-control-with-class-attribute) – Boghyon Hoffmann Jul 12 '21 at 12:14

2 Answers2

0

the answer of your question "Can we update CSS on Data bind" is yes you can with using customData with formatters and writeToDom property true and custom style like

.sapUiIcon[data-yourkey="xxx"] { cursor: default !important; }

Here you can find more details https://openui5.hana.ondemand.com/#docs/guide/1ef9fefa2a574735957dcf52502ab8d0.html

But on the other hand this was a bug at the Icon control itself and fixed at the nightly(1.30) version https://github.com/SAP/openui5/blob/master/src/sap.ui.core/src/sap/ui/core/Icon.js#L443-L448

aborjinik
  • 723
  • 3
  • 5
0

You cannot bind directly to the css classes but you can call myIcon.addStyleClass('bla') on the press handler and make it change accordingly.

Tiago A.
  • 1,392
  • 1
  • 16
  • 26