# Disable a dropdown node on the basis of a switch node result

**URL:** <https://discourse.nodered.org/t/disable-a-dropdown-node-on-the-basis-of-a-switch-node-result/60882>\
**Category:** General\
**Created:** [6 April 2022 14:20 UTC](https://discourse.nodered.org/t/disable-a-dropdown-node-on-the-basis-of-a-switch-node-result/60882 "2022-04-06T14:20:00Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![QGIO](https://avatars.discourse-cdn.com/v4/letter/q/f17d59/32.png) [@QGIO](https://discourse.nodered.org/u/QGIO)\
**Post date:** [6 April 2022 14:20 UTC](https://discourse.nodered.org/t/disable-a-dropdown-node-on-the-basis-of-a-switch-node-result/60882/1 "2022-04-06T14:20:00Z")

</div>

Is there a way to disable a dropdown node on the basis of a switch node result?

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [6 April 2022 15:03 UTC](https://discourse.nodered.org/t/disable-a-dropdown-node-on-the-basis-of-a-switch-node-result/60882/2 "2022-04-06T15:03:24Z")

</div>

You can set the dropdown options in msg.options. So you could feed a empty array as msg.options from one sitch node rule/output  
e.g.

```auto
[{"id":"b0e4145f.4d3e78","type":"inject","z":"bf9e1e33.030598","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"str","x":140,"y":2440,"wires":[["5e5ea156.28aca8"]]},{"id":"5e5ea156.28aca8","type":"switch","z":"bf9e1e33.030598","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"2","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":290,"y":2460,"wires":[["9322575f.976c28"],["76ffd8ee.d2379"]]},{"id":"fbd80ffb.83ea5","type":"inject","z":"bf9e1e33.030598","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"2","payloadType":"str","x":150,"y":2480,"wires":[["5e5ea156.28aca8"]]},{"id":"9322575f.976c28","type":"change","z":"bf9e1e33.030598","name":"","rules":[{"t":"set","p":"options","pt":"msg","to":"[]","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":2440,"wires":[["d16c33a7.cfbce8"]]},{"id":"76ffd8ee.d2379","type":"change","z":"bf9e1e33.030598","name":"","rules":[{"t":"set","p":"options","pt":"msg","to":"[1,2]","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":2480,"wires":[["d16c33a7.cfbce8"]]},{"id":"d16c33a7.cfbce8","type":"ui_dropdown","z":"bf9e1e33.030598","name":"","label":"","tooltip":"","place":"Select option","group":"b9d366f18ff7ae74","order":6,"width":0,"height":0,"passthru":false,"multiple":false,"options":[],"payload":"","topic":"topic","topicType":"msg","className":"","x":680,"y":2460,"wires":[["298f044.73ac97c"]]},{"id":"298f044.73ac97c","type":"debug","z":"bf9e1e33.030598","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":710,"y":2600,"wires":[]},{"id":"b9d366f18ff7ae74","type":"ui_group","name":"test","tab":"ffba43d73860d25d","order":1,"disp":true,"width":12,"collapse":false},{"id":"ffba43d73860d25d","type":"ui_tab","name":"Level","icon":"dashboard","order":3,"disabled":false,"hidden":false}]

```

This would effectively disable selection in the dropdown

---

<div class="post-metadata">

**Author:** ![QGIO](https://avatars.discourse-cdn.com/v4/letter/q/f17d59/32.png) [@QGIO](https://discourse.nodered.org/u/QGIO)\
**Post date:** [7 April 2022 07:05 UTC](https://discourse.nodered.org/t/disable-a-dropdown-node-on-the-basis-of-a-switch-node-result/60882/3 "2022-04-07T07:05:05Z")

</div>

Thnks a lot.

For disable I mean 'not show' the dropdown node in the UI on the base of a switch node output.

Is there a way?

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [7 April 2022 07:10 UTC](https://discourse.nodered.org/t/disable-a-dropdown-node-on-the-basis-of-a-switch-node-result/60882/4 "2022-04-07T07:10:04Z")

</div>

Then put it in its own tab group and use ui-control node to hide or show  
`Groups can be hidden and made visible via a msg like {"group":{"hide":["tab_name_group_name_with_underscores"],"show":["tab_name_another_group"],"focus":true}}`

---

<div class="post-metadata">

**Author:** ![QGIO](https://avatars.discourse-cdn.com/v4/letter/q/f17d59/32.png) [@QGIO](https://discourse.nodered.org/u/QGIO)\
**Post date:** [7 April 2022 07:33 UTC](https://discourse.nodered.org/t/disable-a-dropdown-node-on-the-basis-of-a-switch-node-result/60882/5 "2022-04-07T07:33:29Z")

</div>

Thanks a lot.  
So I need to put the dropdown node alone in a group if I want to hide only the dropdown node, right?

---

<div class="post-metadata">

**Author:** ![QGIO](https://avatars.discourse-cdn.com/v4/letter/q/f17d59/32.png) [@QGIO](https://discourse.nodered.org/u/QGIO)\
**Post date:** [7 April 2022 07:42 UTC](https://discourse.nodered.org/t/disable-a-dropdown-node-on-the-basis-of-a-switch-node-result/60882/6 "2022-04-07T07:42:09Z")

</div>

> [@E1cid](#):
>
> {"group":{"hide":["tab\_name\_group\_name\_with\_underscores"],"show":["tab\_name\_another\_group"],"focus":true}}

How to manage tab name/group name having spaces (e.g. group name = 'Group 5' or 'Group Insert Date')?

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [7 April 2022 07:51 UTC](https://discourse.nodered.org/t/disable-a-dropdown-node-on-the-basis-of-a-switch-node-result/60882/7 "2022-04-07T07:51:16Z")

</div>

tab - `one tab`  
group - `one group`  
would become - `one_tab_one_group`

---

<div class="post-metadata">

**Author:** ![QGIO](https://avatars.discourse-cdn.com/v4/letter/q/f17d59/32.png) [@QGIO](https://discourse.nodered.org/u/QGIO)\
**Post date:** [7 April 2022 07:59 UTC](https://discourse.nodered.org/t/disable-a-dropdown-node-on-the-basis-of-a-switch-node-result/60882/8 "2022-04-07T07:59:05Z")

</div>

But If by the button I need to also switch to another tab ?

I mean, clicking the button I need to go from Tab 1 to Tab 2. and hide a group in Tab2.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [7 April 2022 08:03 UTC](https://discourse.nodered.org/t/disable-a-dropdown-node-on-the-basis-of-a-switch-node-result/60882/9 "2022-04-07T08:03:23Z")

</div>

Please provide an example flow, so we can see exactly what you are trying.

---

<div class="post-metadata">

**Author:** ![QGIO](https://avatars.discourse-cdn.com/v4/letter/q/f17d59/32.png) [@QGIO](https://discourse.nodered.org/u/QGIO)\
**Post date:** [7 April 2022 08:45 UTC](https://discourse.nodered.org/t/disable-a-dropdown-node-on-the-basis-of-a-switch-node-result/60882/10 "2022-04-07T08:45:51Z")

</div>

```auto
[{"id":"5b66b624f2825a62","type":"ui_button","z":"8529dcd4a372f3cb","name":"","group":"e9f2f81a30f4c40e","order":3,"width":"3","height":"1","passthru":false,"label":"button","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"{\"group\":{\"hide\":[\"Inserimento_Date_Controllo_Ricerca_Strumento\"],\"show\":[\"Inserimento_Date_Controllo_Group_5\",\"Inserimento_Date_Controllo_Inserimento_Stato_Tarat./Manut.\",\"Inserimento_Date_Controllo_Storico_Date_Controllo\",\"Inserimento_Date_Controllo_Inserimento_data_controllo\"],\"focus\":true}}","payloadType":"json","topic":"Inserimento Date Controllo","topicType":"str","x":830,"y":1100,"wires":[["4586c2ee579213f5"]]},{"id":"875cb0528d70fca5","type":"ui_text_input","z":"8529dcd4a372f3cb","name":"","label":"","tooltip":"","group":"e9f2f81a30f4c40e","order":2,"width":"1","height":"1","passthru":true,"mode":"text","delay":300,"topic":"topic","sendOnBlur":true,"className":"","topicType":"msg","x":580,"y":1100,"wires":[["4329e68995a31ee2","5b66b624f2825a62"]]},{"id":"4329e68995a31ee2","type":"debug","z":"8529dcd4a372f3cb","name":"text","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":770,"y":1040,"wires":[]},{"id":"23fb4653316f2558","type":"ui_ui_control","z":"8529dcd4a372f3cb","name":"Go to Inserimento Date","events":"all","x":1530,"y":1100,"wires":[[]]},{"id":"4586c2ee579213f5","type":"change","z":"8529dcd4a372f3cb","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"topic","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1020,"y":1100,"wires":[["24fa6dea16207b0b"]]},{"id":"24fa6dea16207b0b","type":"function","z":"8529dcd4a372f3cb","name":"Set msg payload","func":"\n/* ui-control payload */\n/*msg.payload1 = { tab: {\n show : [\"[Tab 7] \"],\n hide : [\"[Home] \"]\n }\n};*/\n\nmsg.payload=msg.topic;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1250,"y":1100,"wires":[["23fb4653316f2558"]]},{"id":"e9f2f81a30f4c40e","type":"ui_group","name":"Group 2","tab":"c4b6a8a406b3fbe5","order":4,"disp":false,"width":"25","collapse":false,"className":""},{"id":"c4b6a8a406b3fbe5","type":"ui_tab","name":"Inserimento Strumento-Attrezzatura","icon":"dashboard","order":3,"disabled":false,"hidden":true}]

```

I made an extraction of a complex flow.  
Let consider that I was passing a topic to switch to the other tab.  
I tried to add the message as in you example to hide the group of the other tab, but it doesn't work.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [7 April 2022 11:16 UTC](https://discourse.nodered.org/t/disable-a-dropdown-node-on-the-basis-of-a-switch-node-result/60882/11 "2022-04-07T11:16:45Z")

</div>

Her is an example of switching tabs and hiding and showing groups.

```auto
[{"id":"5b66b624f2825a62","type":"ui_button","z":"bf9e1e33.030598","name":"","group":"b78a81a5.aff9e","order":1,"width":"3","height":"1","passthru":false,"label":"goto tab 3","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"1","payloadType":"num","topic":"Inserimento Date Controllo","topicType":"str","x":330,"y":2800,"wires":[["24fa6dea16207b0b"]]},{"id":"24fa6dea16207b0b","type":"function","z":"bf9e1e33.030598","name":"Set msg payload","func":"\n/* ui-control payload */\nmsg.payload = {\"tabs\":{\"hide\":[\"Tab_2\"],\"show\":[\"Tab_3\"]}} // hide home tab show tab2\nnode.send(msg);\n\n \n \n msg.payload = {\"group\":{\"hide\":[\"Tab_3_Group_2\"],\"show\":[]}} // hide Group_1 on tab2\n node.send(msg)\n \n msg.payload = \"Tab 3\" ///goto tab 3\n node.send(msg)\nreturn null;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":500,"y":2800,"wires":[["23fb4653316f2558"]]},{"id":"23fb4653316f2558","type":"ui_ui_control","z":"bf9e1e33.030598","name":"Go to Inserimento Date","events":"all","x":770,"y":2800,"wires":[[]]},{"id":"426a5f49.fb1e98","type":"function","z":"bf9e1e33.030598","name":"Set msg payload","func":"msg.payload = {\"tabs\":{\"hide\":[\"Tab_3\"],\"show\":[\"Tab_2\"]}} // hide tab 3 and show tab 2\nnode.send(msg);\n\nmsg.payload = {\"group\":{\"hide\":[\"Tab_2_Group_2\"],\"show\":[\"Tab_2_Group_2\"]}} // show Group_1 on tab2\nnode.send(msg);\n \nmsg.payload = \"Tab 2\"; // goto home tab\nnode.send(msg);\nnode.done();\nreturn null;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":480,"y":2980,"wires":[["23fb4653316f2558"]]},{"id":"f5e80077.6065e","type":"function","z":"bf9e1e33.030598","name":"Set msg payload","func":"msg.payload = {\"group\":{\"hide\":[],\"show\":[\"Tab_3_Group_2\"]}} // show Group_2 on tab3\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":520,"y":3020,"wires":[["23fb4653316f2558"]]},{"id":"a96f6a0f.a924e8","type":"function","z":"bf9e1e33.030598","name":"Set msg payload","func":"msg.payload = {\"group\":{\"hide\":[],\"show\":[\"Tab_2_Group_2\"]}} // show Group_2 on tab2\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":520,"y":2840,"wires":[["23fb4653316f2558"]]},{"id":"7ecfcce7.639f84","type":"ui_button","z":"bf9e1e33.030598","name":"","group":"187a0d10.a44d4b","order":1,"width":0,"height":0,"passthru":false,"label":"goto tab 2","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"1","payloadType":"str","topic":"topic","topicType":"msg","x":290,"y":2980,"wires":[["426a5f49.fb1e98"]]},{"id":"e67f361e.73","type":"ui_button","z":"bf9e1e33.030598","name":"","group":"187a0d10.a44d4b","order":1,"width":0,"height":0,"passthru":false,"label":"show group 2","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"1","payloadType":"str","topic":"topic","topicType":"msg","x":330,"y":3020,"wires":[["f5e80077.6065e"]]},{"id":"29474bad.494aa4","type":"ui_button","z":"bf9e1e33.030598","name":"","group":"b78a81a5.aff9e","order":2,"width":0,"height":0,"passthru":false,"label":"show group 2","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"1","payloadType":"str","topic":"topic","topicType":"msg","x":310,"y":2840,"wires":[["a96f6a0f.a924e8"]]},{"id":"e3c3bd4b.250da8","type":"ui_text","z":"bf9e1e33.030598","group":"977b1749.a3ea48","order":0,"width":0,"height":0,"name":"","label":"text","format":"tab 2 group 2 text","layout":"row-spread","className":"","x":530,"y":2740,"wires":[]},{"id":"1fc2649b.1f8903","type":"ui_text","z":"bf9e1e33.030598","group":"a9448416.fe8fa","order":0,"width":0,"height":0,"name":"","label":"text","format":"tab 3 group 2 text","layout":"row-spread","className":"","x":530,"y":2880,"wires":[]},{"id":"b78a81a5.aff9e","type":"ui_group","name":"Group 1","tab":"df32c4cd.bf03e","order":1,"disp":true,"width":6},{"id":"187a0d10.a44d4b","type":"ui_group","name":"Group 1","tab":"8abb3dd0.ddf87","order":1,"disp":true,"width":"6","collapse":false,"className":""},{"id":"977b1749.a3ea48","type":"ui_group","name":"Group 2","tab":"df32c4cd.bf03e","order":2,"disp":true,"width":6},{"id":"a9448416.fe8fa","type":"ui_group","name":"Group 2","tab":"8abb3dd0.ddf87","order":2,"disp":true,"width":6},{"id":"df32c4cd.bf03e","type":"ui_tab","name":"Tab 2","icon":"dashboard","order":6,"disabled":false,"hidden":false},{"id":"8abb3dd0.ddf87","type":"ui_tab","name":"Tab 3","icon":"dashboard","order":8,"disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

**Author:** ![QGIO](https://avatars.discourse-cdn.com/v4/letter/q/f17d59/32.png) [@QGIO](https://discourse.nodered.org/u/QGIO)\
**Post date:** [7 April 2022 14:56 UTC](https://discourse.nodered.org/t/disable-a-dropdown-node-on-the-basis-of-a-switch-node-result/60882/12 "2022-04-07T14:56:09Z")

</div>

many thanks!!!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [21 April 2022 14:56 UTC](https://discourse.nodered.org/t/disable-a-dropdown-node-on-the-basis-of-a-switch-node-result/60882/13 "2022-04-21T14:56:57Z")

</div>

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