Reactive: Set icon from variable

Hello,

Is there a way to dinamically set the Icon from a variable?
I've found an old solution that implied forcing the class in the extended properties of the Icon with "fa fa-"+the name of the icon.

But this is not working, the Icon simply isn't showing. Is there any work around?


Thanks,

Joaquim

mvp_badge
MVP
Solution

Hi Joaquim,

I just checked, and it's exactly what we do (Traditional Web):

Where the Static Entity "MainEnergieIcons" contains:

Kilian Hekhuis wrote:

Hi Joaquim,

I just checked, and it's exactly what we do (Traditional Web):

Where the Static Entity "MainEnergieIcons" contains:

 Thanks a lot, I was messing up, but your example helped me!
Joaquim

 

mvp_badge
MVP

Hi Joaquin,

You can use a IF statement in the screen to define the icon.

The point is to have every single Icon available, so that's not really a practical solution!

mvp_badge
MVP

Joaquim Mauricio wrote:

The point is to have every single Icon available, so that's not really a practical solution!

Ok, I got it now.


mvp_badge
MVP

Hi Joaquim,

The original solution should work, so if it doesn't (seem to), perhaps there's something wrong with your code?

mvp_badge
MVP

Sample:



mvp_badge
MVP

Leandro: like Joaquim wrote, that's not a solution if you have a large number of dynamic icons to support.

mvp_badge
MVP
Solution

Hi Joaquim,

I just checked, and it's exactly what we do (Traditional Web):

Where the Static Entity "MainEnergieIcons" contains:

Kilian Hekhuis wrote:

Hi Joaquim,

I just checked, and it's exactly what we do (Traditional Web):

Where the Static Entity "MainEnergieIcons" contains:

 Thanks a lot, I was messing up, but your example helped me!
Joaquim

 

mvp_badge
MVP

Glad I could be of help :) Happy coding!

This is still working on reactive web?

I can't use the widget icon of richWidgets.

I got the message "'RichWidgets' Only available for Traditional Web apps."...

There's a way to do it on reactive web apps?

Hello Daniel, you can still add the icon name as a class, following the format: "fa-iconname", like fa-trash.

Ok, but for example, which icon are you using on the screen?

I have the name of icon saved on my table, so, I want to show the exactly icon as icon on the screen.

Any! Just did this in a minute so you can check how it works.

You put any icon you want in the screen, and then in the extended properties I am using 

"icon fa" + iconName

The iconName can be replaced by a list.current.item.iconName or whatever is relevant to your case.

Don't forget to add any other classes that you need in your icon (color, size, etc).

DynamicIcon.oml

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.