# Dashboard\_Dropdown doesn't use DataArray

**URL:** <https://discourse.nodered.org/t/dashboard-dropdown-doesnt-use-dataarray/22317>\
**Category:** Dashboard\
**Created:** [27 February 2020 09:43 UTC](https://discourse.nodered.org/t/dashboard-dropdown-doesnt-use-dataarray/22317 "2020-02-27T09:43:34Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Recon](https://avatars.discourse-cdn.com/v4/letter/r/f19dbf/32.png) [@Recon](https://discourse.nodered.org/u/Recon)\
**Post date:** [27 February 2020 09:43 UTC](https://discourse.nodered.org/t/dashboard-dropdown-doesnt-use-dataarray/22317/1 "2020-02-27T09:43:34Z")

</div>

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](https://discourse.nodered.org/t/ui-dropdown-get-result-from-sql/614/17)) to change my Data in the needed form.  
 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/3/639fee351ba07fa55ff6f9e281fea0e96ac6065a.png)

The debug node gives the following answer:  
 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/9/b92c1f7576078ccaf3610d7586194ab5e6871443.png)

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

Can somebody say me where I have a mistake?

Thank you for helping

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [27 February 2020 11:13 UTC](https://discourse.nodered.org/t/dashboard-dropdown-doesnt-use-dataarray/22317/2 "2020-02-27T11:13:02Z")

</div>

If you provide an [export of the flow](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506) it will be easier to see what is happening.

---

<div class="post-metadata">

**Author:** ![Recon](https://avatars.discourse-cdn.com/v4/letter/r/f19dbf/32.png) [@Recon](https://discourse.nodered.org/u/Recon)\
**Post date:** [27 February 2020 11:35 UTC](https://discourse.nodered.org/t/dashboard-dropdown-doesnt-use-dataarray/22317/3 "2020-02-27T11:35:20Z")

</div>

Here you see the export of the flow:

```auto
[{"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":"127.0.0.1","port":"3306","db":"BLA_ALPHA","tz":""},{"id":"895c7501.0a7268","type":"ui_tab","z":"","name":"Diagramme","icon":"dashboard","order":4,"disabled":false,"hidden":true}]

```

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [27 February 2020 11:57 UTC](https://discourse.nodered.org/t/dashboard-dropdown-doesnt-use-dataarray/22317/4 "2020-02-27T11:57:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Recon](https://avatars.discourse-cdn.com/v4/letter/r/f19dbf/32.png) [@Recon](https://discourse.nodered.org/u/Recon)\
**Post date:** [27 February 2020 12:00 UTC](https://discourse.nodered.org/t/dashboard-dropdown-doesnt-use-dataarray/22317/5 "2020-02-27T12:00:16Z")

</div>

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

![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/3/6331d38ba1082710039ec8ea78066fae26682781.png)

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [27 February 2020 12:14 UTC](https://discourse.nodered.org/t/dashboard-dropdown-doesnt-use-dataarray/22317/6 "2020-02-27T12:14:48Z")

</div>

Are you seeing the dropdown list in the dashboard?

---

<div class="post-metadata">

**Author:** ![Recon](https://avatars.discourse-cdn.com/v4/letter/r/f19dbf/32.png) [@Recon](https://discourse.nodered.org/u/Recon)\
**Post date:** [27 February 2020 12:23 UTC](https://discourse.nodered.org/t/dashboard-dropdown-doesnt-use-dataarray/22317/7 "2020-02-27T12:23:46Z")

</div>

Yes I see the Dropdown on the Dashboard.  
 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/2/22026d4d23d284f00444ca6faad56d483478e471.png)

But there are no options inside.  
 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/2/8253662d0c1a84e12f44c285b50eec865293e6d5.png)

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [27 February 2020 12:34 UTC](https://discourse.nodered.org/t/dashboard-dropdown-doesnt-use-dataarray/22317/8 "2020-02-27T12:34:57Z")

</div>

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

```auto
[{"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"]]}]

```

---

<div class="post-metadata">

**Author:** ![Recon](https://avatars.discourse-cdn.com/v4/letter/r/f19dbf/32.png) [@Recon](https://discourse.nodered.org/u/Recon)\
**Post date:** [27 February 2020 12:40 UTC](https://discourse.nodered.org/t/dashboard-dropdown-doesnt-use-dataarray/22317/9 "2020-02-27T12:40:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Recon](https://avatars.discourse-cdn.com/v4/letter/r/f19dbf/32.png) [@Recon](https://discourse.nodered.org/u/Recon)\
**Post date:** [27 February 2020 13:13 UTC](https://discourse.nodered.org/t/dashboard-dropdown-doesnt-use-dataarray/22317/10 "2020-02-27T13:13:32Z")

</div>

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

![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/2/2203275fb68ddea321ee4b4c86086a15af4c926e.png)

Sorry 😬

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [27 February 2020 13:21 UTC](https://discourse.nodered.org/t/dashboard-dropdown-doesnt-use-dataarray/22317/11 "2020-02-27T13:21:53Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Recon](https://avatars.discourse-cdn.com/v4/letter/r/f19dbf/32.png) [@Recon](https://discourse.nodered.org/u/Recon)\
**Post date:** [27 February 2020 13:26 UTC](https://discourse.nodered.org/t/dashboard-dropdown-doesnt-use-dataarray/22317/12 "2020-02-27T13:26:34Z")

</div>

I got it. Thank you very much.

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

![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/0/60392eb529bfa5d6c8d2a9bf781599351c4ca680.png)  
It has to look like this.

---

<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:** [12 March 2020 13:26 UTC](https://discourse.nodered.org/t/dashboard-dropdown-doesnt-use-dataarray/22317/13 "2020-03-12T13:26:34Z")

</div>

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