Global Variable to format Value/Label fields of ui-nodes

I use HTML to format Value Format and Label of UI-nodes. F. e.

<font color = {{msg.color}} >Hallo</font>

msg.color is defined right before the ui-node in the corresponding flows.

I thought, I could globally set my color scheme and re-utilize it with global variables. However,

<font color = {{global.color_x}} >Hallo</font>

isn't recognized. The text is standard white. The same applies if I used global.get("color_x") or global.get('color_x') instead of global.color_x.

I could not find any hint whether this approach in general isn't possible in relation to HTML. Everywhere else I can access global variables in function nodes or ...

Any hint would be highly appreciated. Thanks.

You should be using either CSS classes or style attributes.

1 Like

Hi @jodelkoenig,
When you inject a msg into a UI template node, that msg is pushed to the dashboard. So you can use the msg properties like in your example.
However the Node-RED (node/flow/global) memory context is only available on the server side flow. So it is normal that you can access those properties e.g. in a function-node, since the JS code (which you have entered inside the function node) is running on the server. But you don't have that data available in the dashboard.
Bart

1 Like

Thanks @TotallyInformation. I know I can or better should do the same via CSS or style attributes. The solution with < font color >, however, was easy enough for me to grasp and implement at the time I started with nodered. I think, I should dig a bit into it :smiley:

I see and understand now, why global context is not working here, @BartButenaers . Thanks for your explanation. It makes sense :slight_smile:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.