Set Dynamic CSS value by Object Attribute string value?

0
I was pretty sure you could set CSS attribute values by the attribute value of an entity object, but I can't find again how to set this up. Let's say you have a Status object with the attribute 'Hex (string)' that contains '#f08245', then that value should be applied to the sibling/specified DOM element as 'color'. So my DOM element get's the CSS values 'Color: #f08245'. Note: I want to use string values, not enum's. I thought this could be done with CSS selector helper widget or EnumClass, but I haven't been able to. Am I missing something or does anyone have an idea how to make this happen?
asked
2 answers
6

You can use a snippet of javascript to handle this. The JavaScript Snippet widget in the app store is your best bet. Here's a simple example:

Configure the JavaScript Snippet (Data Source) widget with the JS below and be sure to set up a variable.

this.domNode.previousSibling.style = 'color:${Color}'

This code adds the "color" style to the JS snippet's sibling. So in a setup like this:

You get results like this:

or this:

answered
0

With the EnumClass app store widget you can set an enum value to a certain class, which holds your custom css. May that is what you are looking for?

answered