我见过其他有同样问题的问题,数据似乎是大多数时候的问题。
我确实创建了一个jsfiddle http://jsfiddle.net/gwvoqns8/
(始终记住必须使用 http,而不是 https )
这应该能说明问题
- 我希望在文本框中输入的任何内容都显示为任何名称的另一个命名节点...
- 我使用的代码似乎强制我选择现有的父节点,但我不希望这样。
为什么它说“未定义”有点烦人
$("#addTopLevel").click(function () {
console.log('in this');
if (treeview.select().length) {
console.log('1');
treeview.append({
text: $("#appendNodeText").val()
}, treeview.select());
} else {
//alert("please select tree node");
console.log('2');
}
});
最佳答案
试试这个:
var ds = new kendo.data.HierarchicalDataSource({
data: [
{"Id":1,"ReportGroupName":"Standard Reports","ReportGroupNameResID":null,"SortOrder":1},
{"Id":2,"ReportGroupName":"Custom Reports","ReportGroupNameResID":null,"SortOrder":2},
{"Id":3,"ReportGroupName":"Retail Reports","ReportGroupNameResID":null,"SortOrder":3},
{"Id":4,"ReportGroupName":"Admin Reports","ReportGroupNameResID":null,"SortOrder":5},
{"Id":5,"ReportGroupName":"QA Reports","ReportGroupNameResID":null,"SortOrder":4}
]
});
var treeview = $("#treeview").kendoTreeView({
dataSource: ds,
dataTextField: "ReportGroupName",
loadOnDemand: false
}).data("kendoTreeView");
treeview.expand(".k-item");
$("#addTopLevel").click(function(e) {
var selectedNode = treeview.select();
// passing a falsy value as the second append() parameter
// will append the new node to the root group
if (selectedNode.length == 0) {
selectedNode = null;
}
treeview.append({
ReportGroupName: $("#appendNodeText").val()
}, selectedNode);
});
关于javascript - 尝试添加到根父节点时出现 KendoUI 未定义节点问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35949967/