MVC Kendo 来自数据源的组合框设置值
MVC Kendo Combobox set value from the DataSource
我有这段代码,如何将值 属性 设置为数据源中的第一个元素?
@(Html.Kendo().ComboBox()
.Name("cboShip")
.Placeholder("Select Ship...")
.Filter(FilterType.Contains)
.DataTextField("ShipName")
.DataValueField("ShipId")
.DataSource(s =>
{
s.Read(read => { read.Action("GetShips", "Filter"); });
})
.Events(events => events.Change("cboShipMultiChange"))
.Value('' /*????? I want to get the first element from the DataSource and use it in here*/)
)
来自我的评论:
您应该可以只应用 .SelectedIndex (0) 而不是一个值。在声明中
@(Html.Kendo().ComboBox()
.SelectedIndex(0) //or whatever index you want to apply.
....... removed for brevity
)
我有这段代码,如何将值 属性 设置为数据源中的第一个元素?
@(Html.Kendo().ComboBox()
.Name("cboShip")
.Placeholder("Select Ship...")
.Filter(FilterType.Contains)
.DataTextField("ShipName")
.DataValueField("ShipId")
.DataSource(s =>
{
s.Read(read => { read.Action("GetShips", "Filter"); });
})
.Events(events => events.Change("cboShipMultiChange"))
.Value('' /*????? I want to get the first element from the DataSource and use it in here*/)
)
来自我的评论:
您应该可以只应用 .SelectedIndex (0) 而不是一个值。在声明中
@(Html.Kendo().ComboBox()
.SelectedIndex(0) //or whatever index you want to apply.
....... removed for brevity
)