Need help. I know it's possible because I've done it in the past. But I'm missing something ....

In a table I need to have an icon that changes according to a value that is registered in the table. This value is the name (text) of the icon that will appear in the table row.

How to make? View image



TIA

Alberto Ferreira wrote:


Need help. I know it's possible because I've done it in the past. But I'm missing something ....

In a table I need to have an icon that changes according to a value that is registered in the table. This value is the name (text) of the icon that will appear in the table row.

How to make? View image



TIA


Good morning,

 if you create an if within the name of the icon I think it resolves. For example: if (id = 0, Entities.IconName.volume_off, Entities.IconName.volume_up).


Jorge Miguel Rodrigues

Thanks Jorge

I thought use your solution. But it is not practical for my case.

I do not have two states... but several. It's a kind of product type  (many), each one with a different icon. 


But Thanks

Alberto Ferreira wrote:

Thanks Jorge

I thought use your solution. But it is not practical for my case.

I do not have two states... but several. It's a kind of product type  (many), each one with a different icon. 


But Thanks



And if you create a field in the product with the name of the icon, so you didn't need an if, just use the field saved in the database.


That it Rodrigues


It exactly what I made. But then I couldn't not use the name... I'm missing something....


Thanks again  

Solution

Alberto Ferreira wrote:


Need help. I know it's possible because I've done it in the past. But I'm missing something ....

In a table I need to have an icon that changes according to a value that is registered in the table. This value is the name (text) of the icon that will appear in the table row.

How to make? View image



TIA

Hello , 

Have you tried add an attribute to your product entity of type IconName Identifier, and pass that id on the name of the icon of the table? It worked for me

I didn't actually created a table, but you can replace the "GetProduct" method for your current of the table. 


Hope this helps


Solution

Hi Alberto,

I'd say the typical implementation would be to use a bunch of nested Ifs, but Vera's solution is a good one in case you want to use RichWidgets Icons and you have a single Static Entity for the statusses.

Thanks Vera

Thanks Kilian


I will try and give feedback.



Hello Vera

I used you solution and I get the result I pretend.

The problem was that I save the wrong name of  icons. I missed the "fa-"



Thanks to all