Kendo Grid Foreign Key列显示空白单元格
@(Html.Kendo().Grid((IEnumerable<Doc.Web.Models.Vendor.DocumentsDetails>)Model.documents_lst)
.Name("grid").Scrollable()
.Columns(columns =>
{
columns.Bound(o => o.DocumentRevisionID).Visible(false);
columns.Bound(o => o.Documentnumber).Title("Document #").Width(150);
columns.Bound(o => o.Revision).Title("Revision").Width(80);
columns.Bound(o => o.RevisionDate).Format("{0:dd/MM/yyyy}").Title("Rev Date").Width(85);
columns.Bound(o => o.RevisionStatus).Title("Revision</br> Status").Width(100);
columns.ForeignKey(o => o.DocNumberPurpose, (System.Collections.IEnumerable)ViewData["Purpose"], "Value", "Text")
.Title("Purpose");
})
.DataSource(dataSource => dataSource
.Ajax()
.Model(model => model.Id(o => o.DocumentRevisionID))
)
.Pageable()
.Sortable()
.Filterable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(5)
.Events(events => events.Error("error_handler"))
.Model(model => model.Id(p => p.DocumentRevisionID))
.Read(read => read.Action("EditingInline_Read", "DesignCoverSheet").Data("additionalInfo"))
)
)
在控制器中,我有以下代码创建viewBag
ViewBag.Purpose = rep.ReadPurposeList(Convert.ToInt32(site), 5, "TR");// returns a Select List
我还在编辑器模板文件夹
中有GridForeignKey View@model object
@(
Html.Kendo().DropDownListFor(m => m)
.BindTo((SelectList)ViewData[ViewData.TemplateInfo.GetFullHtmlFieldName("") + "_Data"])
)
答案 0 :(得分:0)
如果您在控制器中将数据设置为 ViewData ,则必须从 ViewData 检索数据