0

我有一个剑道网格,编辑事件使用下面的代码打开一个弹出窗口。

            editable: { mode: "popup",
            template: kendo.template($("#popup_editor").html()),
            update: true,
            destroy: true,
            confirmation: "Are you sure you want to remove this employee? Click OK to delete record."
        }

弹出窗口中再次包含(popup_editor 模板)网格。子网格的编辑设置为“内联”。所以我的问题是......

我希望 subrid 的 Edit 进行 inine 编辑。但我希望“添加新”(工具栏:[{ 名称:“创建”,文本:“添加新员工”}])功能弹出一个模板。这可能吗?

4

1 回答 1

-1

我也遇到了同样的问题,但是在做了 2-3 天的 RnD 之后,得到了解决方案,我通过 dataSource API 和自定义工具栏命令实现了它。

toolbar: [{ text:"Add new record", className: "grid-add-new-record" }], // specify a custom toolbar button

$("#grid .grid-add-new-record").on("click", function(e) {
    var dataSource = $("#grid").data("kendoGrid").dataSource;

    var window = $("<div id='popupEditor'>")
        .appendTo($("body"))
        .kendoWindow({
            title: "Add new record",
            modal: true,
            content: {
                //sets window template
                template: kendo.template($("#createTemplate").html())
            }
        })
        .data("kendoWindow")
        .center();

    //determines at what position to insert the record (needed for pageable grids)
    var index = dataSource.indexOf((dataSource.view() || [])[0]);

    if (index < 0) {
        index = 0;
    }
    //insets a new model in the dataSource
    var model = dataSource.insert(index, {});
    //binds the editing window to the form
    kendo.bind(window.element, model);
    //initialize the validator
    var validator = $(window.element).kendoValidator().data("kendoValidator")

    $("#btnUpdate").on("click", function(e) {
        if (validator.validate()) {
            dataSource.sync(); //sync changes
            window.close();
            window.element.remove();
        }
    });

    $("#btnCancel").on("click", function(e) {
        dataSource.cancelChanges(model); //cancel changes
        window.close();
        window.element.remove();
    });
});

希望这会帮助你。

参考:Telerik 论坛

快乐编码!!

于 2016-07-21T10:34:06.570 回答