加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc – Kendoui MVC EditorTemplateName在PopUp编辑模式

发布时间:2020-12-16 07:19:23 所属栏目:asp.Net 来源:网络整理
导读:我想在KendoUi网格中使用EditorTemplateName作为外键. 当网格编辑模式为InLine时,一切正常,我的模板已加载.但当更改模式为Popup时不加载模板. 怎么解决呢? @(Html.Kendo().GridProduct() .Name("grid") .Columns(columns = { columns.Bound(p = p.ProductId
我想在KendoUi网格中使用EditorTemplateName作为外键.

当网格编辑模式为InLine时,一切正常,我的模板已加载.但当更改模式为Popup时不加载模板.
怎么解决呢?

@(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与Popup时,渲染的处理方式确实不同.对于后者,实际将要使用的编辑器模板是从名称推断出来的,因此您将Product.cshtml模板放在~Views / Shared / EditorTemplates中.

本文详细介绍了这一点:
http://docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/helpers/grid/editor-templates.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读