drop-down-menu - HTML.Kendo().Dropdownlist 设置默认项

标签 drop-down-menu telerik kendo-ui default-value html

如何在 HTML.Kendo().Dropdownlist().HTMLAttribute() 中设置默认项目?

虽然我已经通过代码设置了它。但是它以某种方式从列表中获取一个默认项并将其显示为第一位。

enter image description here

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/

相关文章:

javascript - Bootstrap 切换按钮不起作用

c# - 使用数据注释标记字段 "Read Only"

c# - Telerik RadGrid - 以编程方式修改 FilterMenu 中的文本

c# - Winforms RadPageView 找控件

kendo-ui - 尝试使用附加按钮创建文本输入

jquery - Bootstrap 选择菜单进入下拉菜单

html - 为什么我的 css 下拉菜单上有一个小圆圈?

html - CSS 下拉菜单隐藏在 Google Chrome 中的 Flash(仅)下。

javascript - Kendo UI 从数据源中多选择选定的值

javascript - 使用 CSS/JavaScript 更改 Kendo Chart 工具提示文本颜色