添加新记录按钮在Kendo分层网格中不起作用 [英] Add New Record button not working in kendo hierarchical grid

查看:109
本文介绍了添加新记录按钮在Kendo分层网格中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将新行添加到kendo层次网格的详细信息网格中,但是添加新记录"按钮不起作用.但是,如果我省略了详细网格定义中的filter选项,则该按钮可以工作,但是在关闭过滤的情况下,我无法根据主行将子行分开.

I'm trying to add new row to the detail grid of the kendo hierarchical grid, but the Add new record button not working. However if I omit the filter option in detail grid definition, then the button works, but with filtering off, I can't separate the child rows according to the master row.

我正在添加一张图像来描述问题.

I'm adding an image to describe the problem.

这是我的分层网格代码:

Here is my code for the hierarchical grid:

 var element = $("#grid").kendoGrid({
            dataSource: {
                type: "JSON",
                transport: {
                    read: {
                        url: "/Home/Read",
                        type: "GET"
                    }
                },
                pageSize: 6

            },
            height: 700,
            sortable: true,
            pageable: true,
            selectable: 'row',
            navigatable: true,
            editable: true,
            toolbar: ["create", "save", "cancel"],
            batch: true,
            detailInit: detailInit,
            dataBound: function () {
                this.expandRow(this.tbody.find("tr.k-master-row").first());
            },
            columns: [
                {
                    field: "EmployeeID",
                    title: "Employee ID",
                    width: "50px"
                },
                {
                    field: "EmployeeName",
                    title: "Employee Name",
                    width: "50px"
                }

            ]
        });

        function detailInit(e) {
            $('<div id="childGrid"></div>').appendTo(e.detailCell).kendoGrid({
                dataSource: {
                    type: "JSON",
                    transport: {
                        read: {
                            url: "/Home/Details",
                            type: "POST"
                        }
                    },

                    pageSize: 5,
                    filter: { field: "EmployeeID", operator: "eq", value: e.data.EmployeeID }
                },
                scrollable: false,
                dataBound: function () {
                    this.expandRow(this.tbody.find("tr.k-master-row").first());
                },
                //sortable: true,
                pageable: true,
                selectable: 'row',
                editable: true,
                toolbar: ["create"],
                editable: true,
                batch: true,
                columns: [
                    { field: "Department", title: "Department", width: "30px" },
                    { field: "Designation", title: "Designation", width: "30px" }

                ]
            });

请帮助我进行排序.预先感谢.

Please help me to sort it out. Thanks in advance.

推荐答案

我给出一个更简单的建议,从上一行中获取要追加的html行,如下所示

i give a simpler suggestion get the html row which you want the append from its previous row as below

'var row = $(上一个行选择器").html();'

'var row = $("previous row selectore").html();'

然后将此行添加到表中

$("table").append(row);

$("table").append(row);

之后,请更改ID(如果有)

after then change the id if you have any

这篇关于添加新记录按钮在Kendo分层网格中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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