Dashboard dropdown - Allow object in msg.payload

Hi folks,

To be able to finish another discussion I need to show a list of webcams in a dropdown on my dashboard.

The list of webcams is available as label-value pairs, so I pass pairs these to the UI dropdown node:

msg.options= [ {
    label: "USB2.0 HD UVC Webcam",
    id: "csO9c0YpAf274OuCPUA53CNE0YHlIr2yXCi+SqfBZZ8=" },
    ...
]

And I want to make sure that the first webcam is automatically selected in the dropdown, so I also need to pass the id as selected value:

msg.payload = "csO9c0YpAf274OuCPUA53CNE0YHlIr2yXCi+SqfBZZ8="

Which all works very well:

image

However the status of the dropdown node shows the id, which is not really human readable:

image

It would be nice if the label (instead of the id) could be displayed in the node status. But that means that the msg.payload would also have to allow a label-value pair (beside the current option to only pass a value)!

  • When only a value is passed, that value is displayed as node status (to avoid breaking existing flows).
  • When label-value pair is passed, the label is displayed as node status.

Remark: have been looking at the code, but it is not really clear to me how to implement this. I assume the client (only in case it gets as input a label-value pair) also needs to send a label-value pair back to the server (as soon as another option is selected in the dropdown), so the beforeSend can show the label.

Any thoughts?

Bart

The editor is not a dashboard.

1 Like

However the status of the dropdown node shows the id

It shows msg.payload.

Yes that is correct, but since my msg.payload is only allowed to contain the id (and not the label) it will show the id.

Case closed ...

hmm - but html selects have always worked that way - they have the part you can see in the list and the value they return - they don't return both parts. What gets returned (the id in this case) is up to you... so you can return the name if you want.