495
Views
14
Comments
Solved
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

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP
Solution

Hi Joaquim,

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

Where the Static Entity "MainEnergieIcons" contains:

UserImage.jpg
Joaquim Mauricio

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

 

2021-08-30 15-28-09
Leandro Correa

Hi Joaquin,

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

UserImage.jpg
Joaquim Mauricio

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

2021-08-30 15-28-09
Leandro Correa

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.


2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi Joaquim,

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

2021-08-30 15-28-09
Leandro Correa

Sample:



2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

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

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP
Solution

Hi Joaquim,

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

Where the Static Entity "MainEnergieIcons" contains:

UserImage.jpg
Joaquim Mauricio

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

 

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Glad I could be of help :) Happy coding!

UserImage.jpg
Daniel Nogueira

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?

UserImage.jpg
Joaquim Mauricio

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

UserImage.jpg
Daniel Nogueira

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.

UserImage.jpg
Joaquim Mauricio

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.