We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

MultiSelect ignores <option selected="selected">; separate call to value: Json deserialize Ids required

I was (happily) surprised to see that I can generate a MultiSelect on top of an existing having options selected.
Extract (pseudo code):

2 Replies

ST Stefan February 5, 2019 09:27 PM UTC

Apparently I should not use tags in the post, they don't appear to be escaped. Trying again:

I was (happily) surprised to see that I can generate a MultiSelect on top of an existing select element, which is generated through Razor.
However, the control does not honour any option selected="selected" ..="" values, the input is rendered blank.
In order to get it to work, I had to instantiate it with a JSON serialized array of the selected options and wonder why that should be necessary.
Full sample is here:
https://stackblitz.com/edit/js-4nhpad
As you can see, the input in the sample is blank, despite the HTML output for the having options selected.

Extract (pseudo code):
select id="x" multiple
option 1
option 2 selected
option 3 selected
option 4

let xMultiSelect = new ej.dropdowns.MultiSelect({
placeholder: "Choose Option",
mode: "Box",
//value: @JsonHelper.Serialize(Model.xIds) // xIds is int[]; Why is this required? Why does it pick up options, but not values from selected?
}).appendTo("#x");


PO Prince Oliver Syncfusion Team February 6, 2019 11:11 AM UTC

Hi Stefan, 

Thank you for contacting Syncfusion support. 

We were able to replicate the reported issue in our end. We have confirmed this as bug in the multiselect component. The fix for this issue will be included in our upcoming patch release scheduled on the mid of February 2019. You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link: https://www.syncfusion.com/feedback/4608  

Until then we suggest you use the value property to preselect the value in the component during the rendering time. Kindly refer to the following link for the sample. 


Kindly refer to the following API documentation for further reference : https://ej2.syncfusion.com/javascript/documentation/api/multi-select/#value 

Regards, 
Prince 


Loader.
Up arrow icon