使用 Kendo UI Web v2012.3.1114 时,我遇到的问题是我正在尝试使用我通过 AJAX 调用服务器检索的节点对 TreeView 进行简单的附加,并出现以下错误。
该节点的格式与从正常读取函数返回的数据完全相同。我已经成功地用于data("kendoTreeView").insertBefore(...)
同一棵树并调用,但是当我尝试使用data("kendoTreeView").append(...)
它时失败了。
错误信息:
未捕获的类型错误:对象# 的属性“数据”不是函数 kendo.web.min.js:25
因为我必须能够为以前是叶子的节点创建新的子节点,所以我不能使用任何其他 API 来执行此操作。
我制作了一个jsFiddle,显示了树的定义以及我希望能够做什么。我尝试在 Kendo 网站上引用工作示例,但似乎一旦我使用自定义模式,事情就会向南。
这是我正在使用的来自 jsFiddle 的代码:
function populateHierarchyTree(quotaSetID, columnID, treeDiv) {
var transport = {
read: {
url: '/Quota/QuotaHierarchy/GetQuotaHierarchyChildrenFromParent',
dataType: 'json',
data: { columnDefinitionID: columnID, quotaSetID: quotaSetID, batchSize:10 },
type: 'POST'
}
};
var schema = {
model: {
id: 'id',
hasChildren: 'hasChildren'
}
};
var dataSource = new kendo.data.HierarchicalDataSource({
transport: transport,
schema: schema
});
treeDiv.kendoTreeView({
loadOnDemand: true,
dataSource: dataSource,
dataTextField: "text",
});
}
// This function is called with a single node which contains the exact same structure returned from GetQuotaHierarchyChildrenFromParent used by the read. ParentElement could be anything.
function AddNode(node,parentElement,treeView){
treeView.append(node,parentElement);
}