Set a background colour from the database

0
I’m hoping there’s an easy answer to this. I have saved a list of names and colour values (in hex format) to the database and I want to display these out as tiles to the page. I currently have a list view showing the names, but I can’t find a way to colour the background other than the built in values. How should I proceed? Is there a built in block or widget, or perhaps another way?
asked
4 answers
2

Would like to share another approach that worked for me. I achieved this with a suggestion in forum, but I cant find the forum link any more.

I got this working with CustomString widget, since I was already using CustomString in my project saved me from having another appstore widget in my project. Since you said you are using list view it is possible too. 

In the custom string widget, I called a microflow which returned something like '<div style="height:30px; background-color: ' + $Color/ColorCode + ';"/>' where the colorcode is dynamically take from entity.

Result looks like 

Indeed I also looked at the option that Tim suggested: https://appstore.home.mendix.com/link/app/108838/

Since it told something like, setting the class of Parent class I was bit doubtful if it suits my requirement and did not tried it.

answered
3

I just added inline dynamic styling supper to my classContainer widget. Grab the MPK here and drop it in your project’s /widgets/ folder, then press F4 in Studio Pro.

Let me know if this works for you!

I’ll look to release it to the app store soon.

answered
2

There is an AppstoreApp that does exactly that: https://appstore.home.mendix.com/link/app/108838/

Its description says: “This widget will set classes to the parent element with the help of a string result of a nanoflow and/or microflow.“

answered
-2

Click on a container and modify the style settings in its properties.

Example:

background-color: #fff; 

https://getbootstrap.com/docs/3.3/css/

Hope this helps

answered