kendo grid删除层次结构网格中的行

时间:2014-12-10 17:49:45

标签: jquery kendo-ui grid hierarchy

我想删除kendo网格的层次结构网格中的行。任何人都可以给我看一些例子。

还有一件事,jQuery没有针对层次结构网格中存在的id / class的元素。 jQuery可以将目标元素存在于主kendo网格中,但不能使用id / class来定位/捕获层次结构网格中的元素。

1 个答案:

答案 0 :(得分:0)

要从kendo网格删除行添加命令" destroy"并且可编辑"内联/弹出"。它也适用于层次结构网格。小演示:

  <div id="example">
        <div id="grid"></div>

        <script>
            $(document).ready(function() {
                var element = $("#grid").kendoGrid({
                    dataSource: {
                        type: "odata",
                        transport: {
                            read: "http://demos.telerik.com/kendo-ui/service/Northwind.svc/Employees"
                        },
                        pageSize: 6,
                        serverPaging: true,
                        serverSorting: true
                    },
                    height: 600,
                    sortable: true,
                    pageable: true,
                    detailInit: detailInit,
                    dataBound: function() {
                        this.expandRow(this.tbody.find("tr.k-master-row").first());
                    },
                    columns: [
                        {
                            field: "FirstName",
                            title: "First Name",
                            width: "110px"
                        },
                        {
                            field: "LastName",
                            title: "Last Name",
                            width: "110px"
                        },
                        {
                            field: "Country",
                            width: "110px"
                        },
                        {
                            field: "City",
                            width: "110px"
                        },
                        {
                            field: "Title"
                        }
                    ]
                });
            });

            function detailInit(e) {
                $("<div/>").appendTo(e.detailCell).kendoGrid({
                    dataSource: {
                        type: "odata",
                        transport: {
                            read: "http://demos.telerik.com/kendo-ui/service/Northwind.svc/Orders"
                        },
                        serverPaging: true,
                        serverSorting: true,
                        serverFiltering: true,
                        pageSize: 10,
                        filter: { field: "EmployeeID", operator: "eq", value: e.data.EmployeeID }
                    },
                    scrollable: false,
                    sortable: true,
                    pageable: true,
                    columns: [
                        { field: "OrderID", width: "70px" },
                        { field: "ShipCountry", title:"Ship Country", width: "110px" },
                        { field: "ShipAddress", title:"Ship Address" },
                        { field: "ShipName", title: "Ship Name", width: "300px" },

                        { command: ["destroy"]} // Added the delete command
                    ],
                  editable: "inline" // set edit mode here
                });
            }

层次结构网格在&#34; detailInit&#34; 功能中定义,并且在层次结构网格中添加了destroy命令。 参考here,几乎没有修改。

希望这有帮助!

相关问题