I am working on migrating an apps to dashboard 2.0 . I am testing the dropdown ui_update for dynamicly update the widget.
ui_update.label : works
ui_update_options: nothing display or object Object
It is probably a little detail I missed but I tried to figure it out without success
Print Screen for ui_update_label, abd ui_update_options result
here my values:
options : format values used with dashboard 1.0 -
ui_update_options : Same data as in options with dashboard 2.0 payload name
This data format works well with dashboard 1.0 ( the msg.options). I simple use a change node to copy my query result from msg.options to msg.ui_update_options.
Currently, you have the keys of the object for each type, and then I'm not sure what the value is links too here.
I can make that more explicit in the documentation though, as it's not 100% clear.
If you're open to using the function node, then you could do msg.ui_update.options = msg.ui_update.options.map((b) => {return Object.keys(b)[0] }) to extract a single array of each boat type
Hum .. your way is much cleaner, but I believe it is what I am doing
Actual process
*/ MYSQL Query result */ This one is on boat name -
[
{"id":6,"name":"Free at Last1"},
{"id":73,"name":"ISOLA"}
]
//Reformat array to work with dropdown
var reformattedArray = msg.payload.map(obj =>{
//declare the reformatted object
var rObj = {};
rObj[obj.name] = obj.id;
return rObj;
});
//Dashboard version 1
msg.options = reformattedArray;
//dashboard version 2
msg.ui_update.options= reformattedArray;
return msg;
/* re-arranged data */
[{"Free at Last1":6},{"ISOLA":73}]
I see -- I must keep value: and label: -- I tought is was only to show the value type ..
so, my data should look like this:
[
{
"value": "1",
"label": "Free at Last1"},
{ "value": "73",
"label": "ISOLA" }]