uiv-lib/uiv

Pre-selected Option in Multiselect component [Question]

etino opened this issue · 3 comments

etino commented

Hello, I need to preselect an option in a MultiSelect component.
Options have the following format

options: [ {label: "Label 1", value: Object1}, {label: 'Label 2: value: Object}, ...]

I've tried to put my preselected option in the selection binding array

this.selection.push(Object)

but the Multiselect display [object Object] value as Label.

Screenshot
image

How can I set correctly a pre-selected option?

Thank you for your help

wxsms commented

You need to push the value into your selected array. If the value is an object, make sure that you're pushing the same reference of it.

Here is a demo: https://codepen.io/wxsm/pen/ZEOBLqK

etino commented

I confirm that's what I expected.
Thank you @wxsms :-)

wxsms commented

welcome.