Automated text color changer

0
Im currently working on a personal project (a soccer app). Currently, I’ve created a list view of all objects of an entity called ‘Games’. (So basically i see an overview of all the played games) What i want to do i change the color of 1 label in the list view ([GameOutcome]) based on the outcome of that game: The label has to be green when we won the game The label has to be red when we lost the game The label has to be blue if it was a draw Is it possible to change the color of a label by using e.g. a microflow? If yes, how?
asked
2 answers
2

Hi Jannes,

Adding on Pjotr’s response, you have to create an enum for game outcome but if you don't want to use the widget then you can add a container for each enum value and conditional visibility on each container. 

E.g. If the game outcome enum has got three values (Won, Lost, Draw) then add three containers and conditional visibility ;
Container 1 = Add visibility and styles (only visible if game outcome enum value = Won. Add green class in your stylesheet and use that class name on the label or use ‘text-success’ helper class. You can also add inline style color:green;

Container 2 = Add visibility and styles (only visible if game outcome enum value = Lost. Add red class in your stylesheet and use that class name on the label or use ‘text-danger’ helper class. You can also add inline style color:red;

Container 3 = Add visibility and styles (only visible if game outcome enum value = Draw. Add blue class in your stylesheet and use that class name on the label or use ‘text-primary’ helper class if you have not changed the default brand-primary label. You can also add inline style color:blue;

 

Hope this helps!

answered
0

You can try using the enumclass widget:

https://appstore.home.mendix.com/link/app/2641/

How to implement:

  • Put the label in the same container with the enumclass widget
  • Make the attribute which stores the game outcome an enum, and give each value a different class in the widget
  • For each class specify the desired color in your stylesheet

 

 

answered