我正在使用 ASP.NET MVC5。 View 从 Controller 获取模型:
public class IncidentWorkbenchViewModel
{
public List<string> ActiveUserList { get; set; }
}
我想出了如何使用 ASP.NET 包装器的 Kendo UI 通过以下方式将列表绑定(bind)到 Kendo DropDownList:
@(Html.Kendo().DropDownListFor(m => m.ActiveUserList)
.BindTo(Model.ActiveUserList).Name("selectedUser")))
现在我想知道如何在不使用 HTML 帮助器的情况下执行相同的操作。我认为使用 javascript 而不是包装器对我来说更好,以便更好地分离代码。
最佳答案
等效的 JavaScript 是:
<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
关于javascript - 如何在不使用 html 包装器的情况下将 View 模型数据绑定(bind)到 Kendo DropDownlist,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38770694/