如何在 HTML.Kendo().Dropdownlist().HTMLAttribute() 中设置默认项目?
虽然我已经通过代码设置了它。但是它以某种方式从列表中获取一个默认项并将其显示为第一位。
May be its getting it somewhere from the code.But i am not able to finding out.And that's why i want to set the default item("--Select--") from somewhere else. And i am thinking about setting it from .HTMLAttributes().
有人知道这样做的正确方法吗?如果是,那么我们该怎么做?否则没有那么有任何其他方法可以解决它吗?
我正在使用以下代码绑定(bind) Kendo 下拉列表:
@(Html.Kendo().DropDownList()
.Name("SelectedMediaType")
.DataTextField("Text")
.DataValueField("Text")
.Value(Model)
.BindTo(ViewBag.MediaTypes)
)
我在其中将 Dropdownlist 与 ViewBag.MediaTypes 绑定(bind)。
那么有没有办法设置viewbag绑定(bind)后的默认值呢?
最佳答案
我是 KendoUI 的新手,但我相信您可以使用 .value 属性设置默认值:http://docs.kendoui.com/api/web/dropdownlist#configuration-value
$("#dropdownlist").kendoDropDownList({
dataSource: ["Car", "Bike", "T.V", "--Select One--"],
value: "--Select One--"
});
关于drop-down-menu - HTML.Kendo().Dropdownlist 设置默认项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18149923/