0
votes

I am trying to set the src property of sap.ui.core.Icon based upon data being fetched from the data model. Something like this:

<Icon src="{= ${propertyname} === 'somevalue' ? 'sap-icon://arrow-top' : 'sap-icon://arrow-bottom'}"/>

I have one additional condition in my case which implies that:

  • Set icon1 (say 'sap-icon://arrow-top') when property value is 'UP'
  • Set icon2 (say 'sap-icon://arrow-bottom') when property value is 'DOWN'
  • Set icon3 (say 'sap-icon://arrow-left') for all other cases

Is it possible to achieve this without the use of formatter function?

1

1 Answers

1
votes

Simply nest another ternary operator inside your expression.

<Icon src="{= ${propertyname} === 'UP' ? 'sap-icon://arrow-top' : ${propertyname} === 'DOWN' ? 'sap-icon://arrow-bottom' : 'sap-icon://arrow-left'}"/>