我尝试将新行添加到kendo分层网格的详细网格中,但添加新记录按钮无法正常工作。但是,如果我在详细的网格定义中省略了过滤器选项,那么该按钮可以工作,但是在过滤掉的情况下,我无法根据主行分隔子行。
我添加了一张图片来描述问题。
以下是我的分层网格代码:
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" }
]
});
请帮我解决一下。提前谢谢。
答案 0 :(得分:0)
我给出一个更简单的建议来获取你想要从上一行追加的html行,如下所示
&#39; var row = $(&#34; previous row selectore&#34;)。html();&#39;
然后将此行追加到表
$(&#34;表&#34)附加(行);
如果你有任何,那么在之后更改id