简体   繁体   English

用于创建按钮的KendoUI网格自定义弹出模板

[英]KendoUI Grid Custom Popup template for create button

i have installed KendoGrid with POPUP option. 我已经用POPUP选项安装了KendoGrid。

Now i am stuck someplace and i cant find any help to fix it with the way i want.. 现在我被困在某个地方,我找不到以我想要的方式来修复它的任何帮助。

So here is problem that i am facing with KendoGrid popup editing. 所以这是我面对KendoGrid弹出式编辑的问题。

When i click ADD New Record, the header on Top shows Edit, same as it shows on when i click on Edit. 当我单击“添加新记录”时,顶部的标题显示“编辑”,与单击“编辑”时显示的标题相同。

http://jsfiddle.net/valchev/BCBzS/1/ http://jsfiddle.net/valchev/BCBzS/1/

also the button shows Update, instead it should be save button on create popup window.. 该按钮也显示“更新”,而应该是“创建”弹出窗口上的“保存”按钮。

i think i have to add something more like this below for creating new record.. 我想我必须在下面添加更多类似内容来创建新记录。

editable: {
    mode: "popup",
    template: kendo.template($("#popup_editor").html())
},

and have the popup create template different from edit template? 并且弹出窗口创建模板与编辑模板不同?

Can anyone help me resolve this issue? 谁能帮我解决这个问题?

If you look at the demo page for popup editing this seems to be the normal behaviour... 如果您查看演示页面以进行弹出式编辑,这似乎是正常的行为...

But you can trick and use the edit event of the grid in order to change that. 但是您可以欺骗并使用网格的edit事件来更改它。 Just add at the beginning of this event the following code : 只需在此事件开始时添加以下代码:

if(!e.model.Id) {
    $(".k-window .k-window-title").text("Add new record");
    $(".k-window .k-grid-update").html("<span class=\"k-icon k-update\"></span>Create");
}   

See the updated jsFiddle . 请参阅更新的jsFiddle

You can use Kendo UI grid localization for changing the popup titles. 您可以使用Kendo UI网格本地化来更改弹出标题。

For changing the Edit title you should define in the grid: 要更改“ Edit标题,应在网格中定义:

editable  : {
    mode : "popup",
    window : {
        title: "Create",
    }
},

For changing the label of the buttons we need to do a little trick... Those labels can be localized in column.command as follow: 为了更改按钮的标签,我们需要做一些技巧...这些标签可以在column.command本地化,如下所示:

columns   : [
    {
        command: [
            {
                name: "edit",
                text: { edit: "Modify", update: "Save", cancel: "Cancel"}
            }
        ],
    },
    ...

The problem is that both window title and button labels are shared between edit and create buttons so changing one you change both. 问题在于,窗口标题和按钮标签在编辑和创建按钮之间共享,因此更改一个将同时更改它们。 Can you find some labels that work for both? 您能找到一些对两者都适用的标签吗?

See it running in JS Fiddle 看到它在JS Fiddle中运行

Do this by adding Following Code 通过添加以下代码来做到这一点

                           edit: function (e) { if (!e.model.isNew()) {
                                e.container.kendoWindow("title", "Update Address");
                            } else {
                                e.container.kendoWindow("title", "New Address");
                            }
                        }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM