我正在尝试创建Kendo Dropdownlist,由于某种原因,它不会调用read.Action。我无法弄清楚我想念的是什么。
我已将read.Action设置为不同的方法,并且它可以工作,但不会将其调用到此特定方法。我已验证自己的拼写正确,并且已在所有内容上设置断点以查找其运行方式。
@(Html.Kendo().DropDownList()
.Name("productionline-dropdown")
.DataTextField("Id")
.DataValueField("Name")
.DataSource(source =>
{
source.Read(read => { read.Action("GetDropDownList", "Home"); });
})
)
[HttpPost]
public JsonResult GetDropDownList()
{
var productionLines = _productionLineService.GetAll().Select(x => new ProductionLineViewModel
{
Id = x.Id,
Name = x.Name,
CreatedAt = x.CreatedAt,
UPE = x.UPE,
ComputerName = x.ComputerName,
ActiveLine = x.ActiveLine
});
return Json(productionLines, JsonRequestBehavior.AllowGet);
}
我希望我的DropDownList用生产线的名称而不是ID填充。谢谢
答案 0 :(得分:0)
这是因为操作用HttpPost
装饰,而控件显然发送了Get(逻辑上很全)以获取数据。删除此属性,这应该可以解决。