无法在剑道网格中绑定 DropDownList。如果它不在网格内,它工作正常。我尝试使用@(Html.Kendo().DropDownList() .Name("RegionId") .OptionLabel("[|[Select...]|]") .DataTextField("Name") .DataValueField("Id") .DataSource(source => { source.Read(read => { read.Action("FindAll", "region") .Data("filterRegion"); }) .ServerFiltering(true); }) .HtmlAttributes(new { @required = "" }) .Enable(false) .AutoBind(false) .CascadeFrom("CountryId") .ValuePrimitive(true).HtmlAttributes(new { @required = "" }) )并将其绑定为文本框,而不是下拉列表。如何让它绑定下拉列表?注意:值在数据库中没有关系我只需要列并通过代码制作。
1 回答
![?](http://img1.sycdn.imooc.com/533e4ce900010ae802000200-100-100.jpg)
慕工程0101907
TA贡献1887条经验 获得超5个赞
这并不像你想象的那么简单,我害怕。整个实现可以在Telerik的文档中找到。
简而言之,您必须:
创建一个对象(Text-Value 或 Id-Label)以绑定到您的列
为这个类创建一个编辑器模板
@(Html.Kendo().DropDownList()
.Name("Employee") // The name of the widget should be the same as the name of the property.
.DataValueField("EmployeeID") // The value of the dropdown is taken from the EmployeeID property.
.DataTextField("EmployeeName") // The text of the items is taken from the EmployeeName property.
.BindTo((System.Collections.IEnumerable)ViewData["employees"]) // A list of all employees which is populated in the controller.
)
装饰您的财产 [UIHint("ObjectEditor")]
- 1 回答
- 0 关注
- 125 浏览
添加回答
举报
0/150
提交
取消