THe below problem is really driving me nuts from last6 hrs.
I am trying to have a multiselect dropdown box for my view
<div class="col-md-6">
@Html.EditorFor(model => model.SelectedCategoryIds, new { SelectList = Model.AvailableCategories })
<script>
$(document).ready(function() {
var storesIdsInput = $('#@Html.FieldIdFor(model => model.SelectedCategoryIds)').data("kendoMultiSelect");
storesIdsInput.setOptions({
autoClose: false
});
@if (Model.AvailableCategories.Count == 0)
{
<text>
storesIdsInput.setOptions({
enable: false,
placeholder: 'No stores available'
});
storesIdsInput._placeholder();
storesIdsInput._enable();
</text>
}
});
</script>
</div>
where my model properties are like :
[UIHint("MultiSelect")]
public IList<int> SelectedCategoryIds { get; set; }
public IList<SelectListItem> AvailableCategories { get; set; }
the problem is in the view it is generating the multiselect dropdown box but the selected items are not set in that, it is always blank
When i use a ListBoxFor and i can see that the data is been set and it sets selected items
@Html.ListBoxFor(model => model.SelectedCategoryIds, new MultiSelectList(Model.AvailableCategories, "Value", "Text"), null)