我有一个显示所有节点的Treeview。结构就像 .P .P1 .P2 .P3 .B .B1 .B2 .B21 .B22 .B221 .B222 .B3 。C .C1 ≥C2
依此类推。目前,如果我尝试删除B,它会与前端的孩子一起被删除。但是如果我在数据库中看到只有B被删除而且有孩子存在。以下是我用于仅删除父级的查询。任何人都可以通过获取所有节点的列表并检查它是否有孩子然后删除来建议我如何删除孩子。尽快需要帮助。
function treeView() {
var treeMenu = new kendo.data.HierarchicalDataSource({
template: kendo.template($("#treeview-template").html()),
schema: {
data: function (response) {
return JSON.parse(response.d);
},
schema: {
model: {
hasChildren: true,
id: "id",
children: "HasChildren",
hasChildren: "HasChildren",
fields: {
ID: { editable: false, nullable: false, type: "string" },
LINK: { editable: true, nullable: true, type: "string" },
},
}
}
},
transport: {
read: {
url: "/getTest",
contentType: "application/json; charset=utf-8",
type: "POST",
datatype: "json",
},
destroy: {
url: "/Services/Services.asmx/removeTree",
contentType: "application/json; charset=utf-8",
type: "POST",
datatype: "json",
data: { "id": deleteId }
},
parameterMap: function (data, type) {
if ((type == "read") || (type == "update") || (type == "create") || (type == "destroy")) {
return JSON.stringify(data);
} else {
return data;
}
}
}
});
$("#treeview").kendoTreeView({
dataSource: treeMenu,
loadOnDemand: false,
expanded: true,
dataValueField: "id",
dataTextField: ['LINK'],
template: kendo.template($("#treeview-template").html()),
}).data("kendoTreeView");}
剑道树视图:
{{1}}
由于