Reputation: 761
I am using ASP.NET MVC5. The view takes a model from controller:
public class IncidentWorkbenchViewModel
{
public List<string> ActiveUserList { get; set; }
}
I figured out how to bind the list to Kendo DropDownList using the Kendo UI for ASP.NET wrapper in the following way:
@(Html.Kendo().DropDownListFor(m => m.ActiveUserList)
.BindTo(Model.ActiveUserList).Name("selectedUser")))
Now I am wondering how I can do the same without using the HTML helper. I think it's better for me to use javascript instead of wrapper for better code separation.
Upvotes: 0
Views: 2093
Reputation: 12304
The javascript equivalent is:
<input id="selectedUser" />
<script>
var activeUsers= @Html.Raw(Json.Encode(Model.ActiveUserList));
$("#selectedUser").kendoDropDownList({
dataSource: activeUsers,
dataTextField: "Name",
dataValueField: "Id"
});
</script>
http://docs.telerik.com/kendo-ui/api/javascript/ui/dropdownlist
Upvotes: 2