我有一个分层的 Kendo UI 网格(MVC 服务器助手),其中一列是 FK 查找,它由一个编辑器模板支持,该模板对值进行 AJAX 查找。所有这些都完美无缺。不起作用的是该列显示 ID(下拉菜单中的数据值字段)而不是文本(下拉菜单中的数据文本字段)。
这是网格
@(Html.Kendo().Grid<ReceivingLogItemResponse>()
.Name("grid_#=GID#")
.Editable(e => e.Mode(GridEditMode.InCell))
.Sortable()
.Columns( c=>
{
c.Bound(i => i.GID).Hidden();
c.Bound(i => i.SerialNumber);
c.Bound(i => i.PartNumber);
c.Bound(i => i.Description);
c.Bound(i => i.Quantity);
c.Bound(i => i.ItemLotNumber).Title("Lot");
c.Bound(i => i.StatusId).Title("Status");
c.Bound(i => i.CategoryId).EditorTemplateName("ClientCategory");
c.Bound(i => i.LocationCode).Title("Location");
c.Bound(i => i.Comments);
c.Command(e => e.Custom("Add").Click("doItemAdd"));
})
.ToolBar(t => t.Save())
.Selectable(s => s.Type(GridSelectionType.Row))
.DataSource(dataSource => dataSource
.WebApi()
.Model(m =>
{
m.Id(i => i.GID);
m.Field(i => i.GID).Editable(false);
})
.Batch(true)
.ServerOperation(false)
.Read(read => read.Url(apiWrapper.receivingLogItemUrl() + "&receivingLogId=#=GID#").Type(HttpVerbs.Get))
.Update(u => u.Url(apiWrapper.receivingLogItemUpdateUrl()).Type(HttpVerbs.Post))
)
.Events(e => e.DataBound("itemDataBound"))
.ToClientTemplate()
)
这是 EditorTemplate (ClientCategory)
@(Html.Kendo().DropDownList()
.Name("CategoryId")
.DataTextField("Code")
.DataValueField("CID")
.AutoBind(true)
.DataSource(ds => ds.Read(a => a.Url(apiWrapper.clientCategoryUrl()).Data("getClientCategoryID()"))))
该列显示 CID 字段,直到您输入它进行编辑,当下拉菜单显示时,它已填充正确的值。当您转到另一个字段时,它会返回到 CID。
我错过了什么?