[英]How to “BindTo” Kendo Grid AutoComplete to Razor MVC Model List
I am trying to bind the Kendo AutoComplete to the model of a view. 我正在尝试将Kendo AutoComplete绑定到视图模型。 I cannot seem to get it set right.
我似乎无法正确设置它。 This is how i am trying to bind to the model property list
这就是我试图绑定到模型属性列表的方式
The property is a collection of the model as below: 该属性是模型的集合,如下所示:
@Html.ColumnDropDownFor(z => z.Owner, Model.OwnerList.ToKeyValueSelectList()) @ Html.ColumnDropDownFor(z => z.Owner,Model.OwnerList.ToKeyValueSelectList())
This is the HTML View: 这是HTML视图:
@(Html.Kendo().AutoComplete()
.Name("countries")
.Filter("startswith")
.Placeholder("--Select Owner--")
.BindTo("@z.OwnerList")
.Separator(", ")
)
I currently get the control rendered but know values found in the autotype. 我目前已呈现控件,但知道在自动类型中找到的值。 This colelction property does work when i use a control like below so i know there are values in it.
当我使用如下所示的控件时,此colelction属性确实起作用,因此我知道其中包含值。
@Html.ColumnDropDownFor(z => z.Recipient, Model.OwnerList.ToKeyValueSelectList())
The BindTo
method expects a collection of objects, but you are passing a string instead. BindTo
方法需要一个对象集合,但是您正在传递一个字符串。 Try this:- 尝试这个:-
.BindTo(Model.OwnerList.ToKeyValueSelectList())
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.