我想在 Kendo Ui 网格中使用 EditorTemplateName 作为外键列。
当网格编辑模式为内联时,一切正常并且我的模板已加载。但是当将模式更改为弹出时不加载模板。
如何修复它?
@(Html.Kendo().Grid<Product>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(p => p.ProductId).Visible(false);
columns.Bound(p => p.Title);
columns.ForeignKey(p => p.CategoryId, new SelectList(ViewBag.CategoryySelectList, "Value", "Text"))
.EditorTemplateName("MyTemplate");
columns.Command(cmd => cmd.Edit());
})
.Editable(edit => edit
.Mode(GridEditMode.PopUp)
)
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(15)
.Events(events => events.Error("error_handler"))
.Model(model =>
{
model.Id(p => p.ProductId);
})
.Read(read => read.Action("FillGrid", "Products"))
.Update(update => update.Action("Edit", "Products"))
.Destroy(destroy => destroy.Action("Delete", "Products"))
)
)
使用时渲染确实处理不一样InLine
/InCell
vs. Popup
。对于后者,实际要使用的编辑器模板是从名称推断出来的,因此您需要添加一个Product.cshtml
模板在~Views/Shared/EditorTemplates
.
本文详细介绍了这一点:http://docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/helpers/grid/editor-templates http://docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/helpers/grid/editor-templates.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)