How to set values dynamically for dropdowns in Node-Red?

3,188 views
Skip to first unread message

Kulasangar Gowrisangar

unread,
Mar 17, 2017, 1:18:47 AM3/17/17
to Node-RED
I'm having a custom node which includes two dropdowns which are independent to each other.

So the second dropdown values changes, according to the selected value from the first drop down. 

What I've tried now is:

  • User drags my custom node (iotinput) choses values from both the drop downs and clicks the Done.
  • He drags another custom node (iotinput) again, and select different values and clicks Done.
  • So there're two custom nodes at the moment.
  • So when the user goes back and click in either one of those nodes, it should show the previously selected values which I'm unable to do at the moment. 
  • So how much custom nodes he's dragging into the flow, the user should be able to see the previously selected values after clicking Done. 
NOTE: All the above I'm doing it without deploying the flow.

The problem I'm facing here is, since I'm loading my dropdowns from an ajax call, I'm unable to load the previously selected values. 

I've checked the in-built nodes in Node-Red which has dropdowns, where the options values are hard coded. I was able to do it for a textbox successfully.

But then I'm clueless, how could I do it for dropdowns which are getting created dynamically? Is there anyway in Node-Red to do it?

Thanks!

Nick O'Leary

unread,
Mar 17, 2017, 6:12:27 AM3/17/17
to Node-RED Mailing List
Hi,

on oneditprepare you have access to the properties of the node. So when you dynamically load the select box content, you can set the preselected value to mach what the node's property is.



Nick

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/3f247523-dc0a-4881-a980-462d8733d308%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nick O'Leary

unread,
Mar 17, 2017, 6:17:54 AM3/17/17
to Node-RED Mailing List

Kulasangar Gowrisangar

unread,
Mar 17, 2017, 8:48:29 AM3/17/17
to Node-RED
Thank you so much @Nick!

 I'm still working on it. :) 
Reply all
Reply to author
Forward
0 new messages