Kendoui MVC EditorTemplateName 在 PopUp 编辑模式下不起作用 [英] Kendoui MVC EditorTemplateName do not work in PopUp edit mode

查看:21
本文介绍了Kendoui MVC EditorTemplateName 在 PopUp 编辑模式下不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将 EditorTemplateName 用于 KendoUi 网格中的外键列.

I want to use EditorTemplateName for foreign key Column in KendoUi grid.

当网格编辑模式为内联时,一切正常并且我的模板已加载.但是当将模式更改为 Popup 时不会加载模板.怎么解决?

when Grid Edit Mode is InLine all thing is OK and My Template Loaded. but when change mode to Popup not load template. how can fix it?

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

The rendering is indeed not handled the same when using InLine/InCell vs. Popup. For the latter, the editor template that is actually going to be used is inferred from the name, so you'd put a Product.cshtml template in ~Views/Shared/EditorTemplates.

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

This article covers this in detail: http://docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/helpers/grid/editor-templates.

这篇关于Kendoui MVC EditorTemplateName 在 PopUp 编辑模式下不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆