I would like to inquire about the dropdown node

I would like to inquire about the dropdown node.

I am using a drop-down node. Is it possible to configure the data transmission method to allow transmission only when a button is pressed?

For the current dropdown, if you select it you will go straight to debug.
I want to use this method to send a message only when the button is pressed after selecting the dropdown.

I would like to proceed with the above configuration. Is this possible?

You could use a node-red-contrib-queue-gate to queue the message, then release it from the queue when the button is pressed.

You could use a ui-button, but you have to move the payload to msg.topic and back again after.
e.g.

[{"id":"5e55e0cd0953f847","type":"ui-dropdown","z":"d1395164b4eec73e","group":"9d83cd8b3d5ee33c","name":"","label":"Select Option:","tooltip":"","order":3,"width":0,"height":0,"passthru":false,"multiple":false,"chips":false,"clearable":false,"options":[{"label":"1","value":"1","type":"str"},{"label":"2","value":"2","type":"str"}],"payload":"","topic":"dropdown","topicType":"str","className":"","x":140,"y":180,"wires":[["ba7ce5e6ee8ad483"]]},{"id":"ba7ce5e6ee8ad483","type":"change","z":"d1395164b4eec73e","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"topic","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":180,"wires":[["22ca5be64623ebee"]]},{"id":"22ca5be64623ebee","type":"ui-button","z":"d1395164b4eec73e","group":"9d83cd8b3d5ee33c","name":"","label":"Submit","order":0,"width":0,"height":0,"emulateClick":false,"tooltip":"","color":"","bgcolor":"","className":"","icon":"","iconPosition":"left","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":480,"y":180,"wires":[["5bf347d340903bc9"]]},{"id":"5bf347d340903bc9","type":"change","z":"d1395164b4eec73e","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"topic","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":220,"wires":[["cde5a6749ffaae68"]]},{"id":"cde5a6749ffaae68","type":"ui-text","z":"d1395164b4eec73e","group":"9d83cd8b3d5ee33c","order":1,"width":0,"height":0,"name":"","label":"text","format":"{{msg.payload}}","layout":"row-spread","style":false,"font":"","fontSize":16,"color":"#717171","className":"","x":650,"y":220,"wires":[]},{"id":"9d83cd8b3d5ee33c","type":"ui-group","name":"Group1","page":"c694d0ebe0d2b702","width":"6","height":"1","order":1,"showTitle":true,"className":"","visible":"true","disabled":"false"},{"id":"c694d0ebe0d2b702","type":"ui-page","name":"Page1","ui":"1805777f90e92057","path":"/page1","icon":"home","layout":"grid","theme":"a965ccfef139317a","order":2,"className":"","visible":"true","disabled":"false"},{"id":"1805777f90e92057","type":"ui-base","name":"dashboard","path":"/dashboard","includeClientData":true,"acceptsClientConfig":["ui-notification","ui-control"],"showPathInSidebar":false},{"id":"a965ccfef139317a","type":"ui-theme","name":"HN Theme","colors":{"surface":"#5c5c5c","primary":"#00fdff","bgPage":"#383838","groupBg":"#4f4f4f","groupOutline":"#858585"},"sizes":{"pagePadding":"12px","groupGap":"12px","groupBorderRadius":"4px","widgetGap":"12px"}}]

@joepavitt, If we can set payload of a button node to flow, global, etc why can we not set it to a msg property. Seems passing on a incoming payload has a use.

I don't really want to have the button node itself used as a state store. That's what Node-RED's context store's are for.

In Node-RED, msg is a live object that doesn't exist once dealt with. In Dashboard, we go against this pattern slightly by having each node have a msg store so that we can revive state on refresh of a dashboard, but having this pattern of using the button as a temporary store is not something I could advocate

I would say doing it that way is a bit of an anti-pattern. I think that ideally the UI should be kept distinct from the logic, embedding the logic in the ui node goes against this. Also, if the button is pressed twice won't that send the last message twice? That may not be what is required.

This is what the dropdown does it store incoming msg options for dynamic content, I fail to see why we can not have dynamic button/switch payloads. I for one would see it as a benefit.

Why would you need to store in context when the value is in the msg and storing is not really required? and may result in race conditions.

A dynamic payloads is not really logic it is giving the possibility of changing the payload dynamically using the incoming msg properties, as the dropdown can do, as well as dynamic content for form or text nodes etc.

This could also be done with a ui form when it is fixed, and prefilling the form does not pass on the payload without a submit.

There is a difference with overriding a configuration (how we do via msg.ui_update.<property>) and using msg.payload here, which is the vast majority of cases represents a value of a widget, which is normally a passing thing.

The race condition is equally applicable in the button as it is in the store?

The Pull Request is open - and mostly works, I submitted a review this afternoon, and am just waiting on one final piece to get fixed.

Then allow button payload to be overridden by an msg .ui_update property, not necessarily msg.payload. I know it is possible now using msg.topic, but the topic may already be i use in the flows logic already.

You are probably correct, but I still do not see the reason to store in context, when the value is available in the msg properties., and there is no reason to store it.

It is possible to do it this way. Thank you so much for your reply.

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