Dashboard_Dropdown doesn't use DataArray

Hi everyone,

ich want to use the ui_dropdown Node to make a selection of some sensors. The id's and names are stored in a mysql database. I used the thread from @knolleary (UI Dropdown - get result from SQL) to change my Data in the needed form.

The debug node gives the following answer:

But the dropdown node say, that the value ist undefined.

Can somebody say me where I have a mistake?

Thank you for helping

If you provide an export of the flow it will be easier to see what is happening.

Here you see the export of the flow:

[{"id":"5652cf9d.e232e","type":"tab","label":"Diagramme","disabled":false,"info":""},{"id":"ec61f421.769e88","type":"inject","z":"5652cf9d.e232e","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":130,"y":60,"wires":[["6c86c495.88178c"]]},{"id":"6c86c495.88178c","type":"function","z":"5652cf9d.e232e","name":"Sensoren abfragen","func":"msg.topic = \"SELECT `ID`, `Name` FROM `komponenten` WHERE `Komponententyp` = 1\";\nreturn msg;","outputs":1,"noerr":0,"x":330,"y":60,"wires":[["4fe5c17a.a153f8"]]},{"id":"23f78aa8.195c9e","type":"function","z":"5652cf9d.e232e","name":"Sensoren fĂĽr DropDown anpassen","func":"var data = msg.payload;\nmsg = {};\n\nmsg.options = data.map(function(value) {\n    var v = {};\n    v[value.Name] = value.ID;\n    return v;\n})\nreturn msg;\n\n/*var objekt = [];\nvar Laenge = msg.payload.length;\n\nvar zaehler = 0;\nwhile (zaehler <= Laenge - 1){\n    var tempArray = {};\n    var Identifier = msg.payload[zaehler].ID;\n    var User = msg.payload[zaehler].Name;\n    tempArray = {1 : User};\n    objekt.push(tempArray);\n    zaehler++;\n}\nmsg.options = objekt;\n\nreturn msg;*/","outputs":1,"noerr":0,"x":860,"y":60,"wires":[["74d54ddb.8a875c","ad684031.8a57f"]]},{"id":"74d54ddb.8a875c","type":"ui_dropdown","z":"5652cf9d.e232e","name":"","label":"","tooltip":"","place":"Select option","group":"bc3130eb.587ef8","order":1,"width":0,"height":0,"passthru":false,"options":[],"payload":"","topic":"","x":1100,"y":60,"wires":[[]]},{"id":"4fe5c17a.a153f8","type":"mysql","z":"5652cf9d.e232e","mydb":"266f9218.e6ca8e","name":"Datenbank BLA_ALPHA","x":570,"y":60,"wires":[["23f78aa8.195c9e"]]},{"id":"ad684031.8a57f","type":"debug","z":"5652cf9d.e232e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"options","targetType":"msg","x":1110,"y":160,"wires":[]},{"id":"bc3130eb.587ef8","type":"ui_group","name":"Group 1","tab":"895c7501.0a7268","order":1,"disp":true,"width":6},{"id":"266f9218.e6ca8e","type":"MySQLdatabase","z":"","host":"","port":"3306","db":"BLA_ALPHA","tz":""},{"id":"895c7501.0a7268","type":"ui_tab","z":"","name":"Diagramme","icon":"dashboard","order":4,"disabled":false,"hidden":true}]

Please add a debug node to the output of the SQL node so I can see what the data looks like.

The first on is the debug node of the SQL Node, the second on is the formated data.


Are you seeing the dropdown list in the dashboard?

Yes I see the Dropdown on the Dashboard.

But there are no options inside.

Do you press the inject button before looking at the dashboard?

If so, try this, add this to your flow (an inject and chnange node and connect it to your ui-drodown and press the inject button. Then see what is in the dashboard

[{"id":"56272c78.bdbe9c","type":"inject","z":"ba53629d.ec0638","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":420,"wires":[["3e98f022.235848"]]},{"id":"3e98f022.235848","type":"change","z":"ba53629d.ec0638","name":"","rules":[{"t":"set","p":"options","pt":"msg","to":"[ \"Choice 1\", \"Choice 2\", {\"Choice 3\":\"3\"} ]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":180,"y":500,"wires":[["9cfcb5b8.5fb8c8","f9af5b23.1200c8"]]}]
1 Like

The Dropdown Menu doesn't change. It looks like before

I have to change my answer. I tried it again and kow I see this:


Sorry :grimacing:

Ok! so now put a debug node on the output of the change node I gave you and run it. Now examine its output and the output of your function node feeding the chart. What differences do you see?

1 Like

I got it. Thank you very much.

The difference was, that I have to change the numbers into a string. No it works fine.

It has to look like this.

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