Preselect option in dynamically filled Dropdown

It is possible to select an option in a prefilled dropdown.
But how can I select an option in an dynamically filled dropdown?

I still made tests with prefilled and dynamically filled dropdown, but only the prefilled dropdown will show the selected option. The dynamially filled dropdown is giving me the output, but the option is not shown on the UI.

Yes by feeding in msg.payload with the value of the selection you want pre selected

e.g.

[{"id":"55f374bb.7d3eb4","type":"inject","z":"7760f563.ea0324","name":"","props":[{"p":"payload"},{"p":"options","v":"[\"one\",\"two\",\"three\"]","vt":"json"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"two","payloadType":"str","x":170,"y":2120,"wires":[["318c812a.d34f46","a3703f7a.e5aee"]]},{"id":"a3703f7a.e5aee","type":"ui_dropdown","z":"7760f563.ea0324","name":"","label":"","tooltip":"","place":"Select option","group":"165e1e1a.e752fa","order":1,"width":0,"height":0,"passthru":true,"multiple":false,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"","x":280,"y":2200,"wires":[[]]},{"id":"165e1e1a.e752fa","type":"ui_group","z":"","name":"Default","tab":"f9b58883.fa613","order":1,"disp":true,"width":"12","collapse":false},{"id":"f9b58883.fa613","type":"ui_tab","z":"","name":"Home","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

I already tested.
I works with prefilled dropdowns, but not with dynamically filled ones:

[{"id":"912a20c6.5c749","type":"ui_dropdown","z":"416fb8ac.762a48","name":"test","label":"test","tooltip":"","place":"test","group":"deeee64c.743b28","order":3,"width":0,"height":0,"passthru":true,"multiple":false,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"test","x":750,"y":900,"wires":[["baf73052.58ae4"]]},{"id":"55f19a36.83c904","type":"inject","z":"416fb8ac.762a48","name":"Setup","props":[{"p":"options","v":"[\"Test 1\",\"Test 2\",\"Test 3\",\"Test 4\",\"Test 5\"]","vt":"json"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"str","x":410,"y":880,"wires":[["878ef56.1168008"]]},{"id":"dab6e71b.37ab28","type":"inject","z":"416fb8ac.762a48","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"test_3","payloadType":"str","x":590,"y":920,"wires":[["912a20c6.5c749","6ce0ff1a.b846f"]]},{"id":"baf73052.58ae4","type":"debug","z":"416fb8ac.762a48","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":910,"y":920,"wires":[]},{"id":"878ef56.1168008","type":"function","z":"416fb8ac.762a48","name":"setup data","func":"var newMsg = {\n    'options': []\n};\n\nfor (i = 0; i < 10; i++) {\n    const name  = 'Test ' + i;\n    const id    = 'test_' + i;\n    var   entry = {};\n    entry[name] = id;\n    newMsg.options.push(entry);\n}\n\nreturn newMsg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":570,"y":880,"wires":[["912a20c6.5c749","dd13caa8.d20698"]]},{"id":"dd13caa8.d20698","type":"debug","z":"416fb8ac.762a48","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":750,"y":860,"wires":[]},{"id":"6ce0ff1a.b846f","type":"ui_dropdown","z":"416fb8ac.762a48","name":"","label":"test","tooltip":"","place":"Select option","group":"deeee64c.743b28","order":4,"width":0,"height":0,"passthru":true,"multiple":false,"options":[{"label":"Test 0","value":"test_0","type":"str"},{"label":"Test 1","value":"test_1","type":"str"},{"label":"Test 2","value":"test_2","type":"str"},{"label":"Test 3","value":"test_3","type":"str"},{"label":"Test 4","value":"test_4","type":"str"},{"label":"Test 5","value":"test_5","type":"str"},{"label":"Test 6","value":"test_6","type":"str"},{"label":"Test 7","value":"test_7","type":"str"},{"label":"Test 8","value":"test_8","type":"str"},{"label":"Test 9","value":"test_9","type":"str"}],"payload":"","topic":"","x":750,"y":940,"wires":[["baf73052.58ae4"]]},{"id":"1b26ffc8.734e4","type":"inject","z":"416fb8ac.762a48","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"test_4","payloadType":"str","x":590,"y":960,"wires":[["912a20c6.5c749","6ce0ff1a.b846f"]]},{"id":"deeee64c.743b28","type":"ui_group","z":"","name":"Information","tab":"cee61e6a.a801e","order":2,"disp":true,"width":"6","collapse":false},{"id":"cee61e6a.a801e","type":"ui_tab","z":"","name":"Konfiguration","icon":"settings","order":1,"disabled":false,"hidden":false}]

my example was dynamic , not prefilled.

Edit/
Your flow works for me and test 3 and test 4 are preselected when i look at dashboard.

What is your system?

I'm on Windows 10,
Node-Red: v1.1.3,
Node.js: v12.19.0,
node-red-dashboard: 2.23.4

Android 6,
Node-Red: v1.1.2,
Node.js: v13,
node-red-dashboard: 2.23.4

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