Kendo UI下拉菜单从模型加载数据
Kendo UI Drop Down loading data from model
我有一个带有产品选择的标准订单。我正在根据以下内容创建一个下拉列表,其中ProductName和ID是产品参考数据模型的属性。ProductID是Order模型的属性。下拉列表已加载,并且在提交表单时工作正常。
我的问题是当用户再次打开此表单以查看他的订单时。我从数据库加载Order模型,可以看到ProductID被正确地加载回来。但是,下拉选择仍然为空。这是标准行为吗?也许我需要执行一些额外的任务。kendo ui不是自动翻译产品ID以在下拉列表中显示产品名称吗?
@model int
@(Html.Kendo().DropDownList()
.Name("ProductID")
.OptionLabel(" ")
.DataTextField("ProductName")
.DataValueField("ID")
.DataSource(source =>
{
source.Read(read =>
{
read.Action("RefDataClientSelection_Read", "RefDataClient").Type(HttpVerbs.Post); //Set the Action and Controller name
})
.ServerFiltering(true); //If true the DataSource will not filter the data on the client.
})
)
尝试使用DropDownListFor()
,如下所示:
@model int
@(Html.Kendo().DropDownListFor(m => m) // or m => m.ProductId if you have a more complex model
.OptionLabel(" ")
.DataTextField("ProductName")
.DataValueField("ID")
.DataSource(source =>
{
source.Read(read =>
{
read.Action("RefDataClientSelection_Read", "RefDataClient").Type(HttpVerbs.Post); //Set the Action and Controller name
})
.ServerFiltering(true); //If true the DataSource will not filter the data on the client.
})
)
相关文章:
- 正在等待呈现图表,直到加载数据为止
- ng绑定和ng href问题.ng href未从控制器加载数据
- 单击按钮时加载数据
- 在reactjs组件中预加载数据
- Highcharts可以从服务器加载数据,但不能更新
- AngularJS promise在加载数据之前得到解决
- 在Knockout JS中搜索从DB加载数据的项目
- 如何在angular js中使用$emit后重新加载数据
- 构建多个图表时,HighCharts加载数据的速度较慢
- 加载初始网站后在后台加载数据
- ExtJS网格未从Ext.data.XmlStore加载数据
- 数据表 AJAX 筛选器重新加载数据
- select2 使用 AJAX 加载数据不能选择任何选项
- 在 Metro 风格应用中启动时加载数据
- 需要帮助使用 AJAX 和其他一些东西加载数据
- Vue 不加载数据
- 向右滚动加载数据
- 为SEO的数据绑定JS预加载数据
- mysql循环-预加载数据
- 无法使用JSON加载数据表