Multiselect List output with keys?

Hi guys,

I have the following issue. I am using a table element with multiselect enabled and only one column in a JSON statement, basically like this:

{
"003" : {{ table1.selectedRow.data }}
}

And the result is this:

{
"003" : [{"zubehor_dokument":1},{"zubehor_dokument":3}]
}

However I just found the Multiselect Listbox component and would like to use that one instead but I am not gettin the same result.

With the Multiselect Listbox component this:

{
"003" : {{ multiselectListbox1.values }}
}

Comes out as this:

{
"003" : ["Option 1","Option 2","Option 3"]
}

How can I get it to output like the first table as key value pairs? I don't get it.

You want to use .selectedItems, not .values.

.values is roughly equivalent to a table's .data property while .selectedItems is equivalent to .selectedRow.

Hi Brad,

unfortunately that didn't solve my issue as .selectedItems gives back all data of the component.

However if someone else has the same issue and finds this I solved it by using .selectedItems.map which allowed me to turn the output into key value pairs:

multiselectListbox1.value.map(function(value) {
  return {key: value};
})

Great, glad you got to your destination. :smiley:

1 Like