I need to pre-select items in multi select box.
To do this I use value.
My code:
<div class="form-group">
<label>...</label>
<div class="control-wrapper">
<div class="control-styles">
<ejs-multiselect id="box"></ejs-multiselect>
</div>
</div>
</div>
<script>
function runMultiSelectBox() {
var mainIdsArr = [];
@if (ViewBag.mainIdsStringArray != null)
{
foreach (var d in ViewBag.mainIdsStringArray)
{
<text>mainIdsArr.push(@d);</text>
}
}
var multiSelectObject = new ej.dropdowns.MultiSelect({
dataSource: ej.data.DataUtil.parse.isJson(@Html.Raw(ViewBag.mainIdsJson)),
fields: {
text: "...",
value: "..."
},
htmlAttributes: {
name: "..."
},
maximumSelectionLength: 1000.0,
mode: "Box",
placeholder: "...",
value: mainIdsArr,
zIndex: 9999
});
multiSelectObject.appendTo('#box');
}
runMultiSelectBox();
</script>
Is correct use value?
Attachment:
Capture_340dcaa0.zip