我有一个从 ASP.NET MVC3 控制器加载数据的 Dynatree。对于第一次调用,树需要加载数据,然后树必须按需加载(延迟加载)。我面临的问题是第一次,当数据从控制器返回到树上时,数据没有正确显示。基本上节点名称将变为 NULL。但我检查了控制器是否正确返回数据。如何格式化在客户端收到的数据。
我正在使用以下代码库:
treeElement.dynatree({
title: "Lazy loading sample",
fx: { height: "toggle", duration: 200 },
autoFocus: false,
initAjax: {
url: "/DataManager/ViewNodes",
data: { mode: 'all' }
//Here after I receive the data, how do I show the nodes ??
},
onActivate: function (node) {
alert(node.getKeyPath());
},
onLazyRead: function (node) {
node.appendAjax({
url: ""
});
}
});
从控制器返回的 json 具有以下结构:
[
{"ChildNodes": [],"Parent":null,"Type":9,"HasRaps":false,"HasReports":false,"TotalChildCount":0,"NodePaths":null,"ID":2,"Name":"Omega",},
{"ChildNodes":[{"ChildNodes": [],"Parent":null,"Type":0,"HasRaps":false,"HasReports":false,"TotalChildCount":0,"NodePaths":null,"ID":0,"Name":"LoadingData..."}],"Parent":null,"Type":8,"HasRaps":false,"HasReports":false,"TotalChildCount":1,"NodePaths":null,"ID":14,"Name":"PARIS"}
]
谁能帮忙。
谢谢, 阿尼尔班