Access Node "Name" property to use in a ui_template

#1

I'm using ui_templates to set color background to text boxes. They also have a label which I would like to use the "Name" property of the node to display the label for easy setup and since the name is a blank in the ui_template configuration. It should be easy to access the Name" property, and then reference in the HTML. I looked but I cannot quite get the syntax to use. Can someone please help who knows how?

Thanks,

0 Likes

#2

There a whole separate category where the dashboard experts hang out... https://discourse.nodered.org/c/dashboard

0 Likes

#3

The template inside a ui_template node does not have access to the node's name property.

(Note I have moved this topic over to the dashboard category that @ukmoose pointed at)

0 Likes

#4

knolleary,
Since the ui_template has no access, it's pointless to try and use the name as an internal reference to the label on the HTML object.... Is there a means in the future to allow access to this information in order to facilitate something like this for setup/configuration purposes?

Kind Regards,

0 Likes

#5

The node (and it’s properties like name) are on the server side. The ui_template and other ui_ elements are browser side. Maybe you could add an id to the template that css could find ?

0 Likes

#6

i tried to access with a function, but the syntax I'm using is not right. I believe I need to upgrade to '0.19'. I'm on '0.18' currently.. according to the doc it can access it but my older version cannot?

0 Likes

#7

In the 0.19 release the Function node will have access to its name property. 0.19 will be released in a couple weeks when Dave and I are both back from holiday.

But that is the Function node accessing its name property. That has nothing to do with the ui_template node accessing its name property.

0 Likes

#8

OK, thanks. I appreciate your time and effort to explain this.

0 Likes

#9

dceejay,
I believe you have something there. I was locked into a thought that these should be constants... Actually it would serve me better if I did as you suggest and send these in the message. That way the values can be dynamic and the display can morph somewhat as products change and the needs for added display items change.

Is there an easy way to make an element not display if it does not have data to match the widget? i.e. loop around areas of HTML to avoid displaying it altogether? It appears that once these are defined they display as per configuration. I have noticed that a test ui_template has affected the display even if there was no message connection to it.

0 Likes

#10

You can use any Angular directives to avoid displaying html elements when certain conditions exist -- e.g.

<img src='go.png' ng-if="msg.payload == 0"></img>
<img src='stop.png' ng-if="msg.payload == 1"></img>
1 Like

#11

Thanks shrickus,

I'll take a closer look at this. It looks like I need an education on Angular. I had no idea how to do any conditional statements in HTML/CSS, or if it was even possible.

0 Likes