这是我的Kendo Treeview的代码。我无法为所选节点添加新节点。
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",
},
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");}
添加代码:
function addNode(curr) {
var treeview = $("#treeview").data("kendoTreeView");
console.log('currObj = ' + currObj);
var selectedNode = treeview.select();
var selectedNode = $(currObj);
if (selectedNode.length == 0) {
selectedNode = null;
}
var LABEL=prompt("Please enter desired Node name","Default");
if (LABEL == null) {
return;
}
treeview.append(LABEL, selectedNode);
}
输入节点后获取错误" TypeError:o未定义"。任何人都可以帮助我。
由于