Dynatree 有加载 json 格式指南吗?
我正在尝试通过 ajax 使用 json 对象加载 dynatree。我无法控制对象内的 json 名称和值。它们将采用以下格式。我无法加载树。 json 是否需要采用特定格式才能正确加载?
这是 JSON
{
"root":true,
"topNode": {
"containerId":"1",
"children":[
{
"containerId":"2",
"children":[
],
"root":false
},
{
"containerId":"3",
"children":[
{
"containerId":"4",
"children":[
],
"root":false
}
],
"root":false
},
{
"containerId":"5",
"children":[
{
"containerId":"6",
"children":[
],
"root":false
},
{
"containerId":"7",
"children":[
],
"root":false
}
],
"root":false
}
],
"root":true
}
}
这是 Javascript:
$(function(){
$("#treeView").dynatree({
initAjax: {
url: "/myURL",
},
});
});
I am trying to load dynatree using a json object via ajax. I dont have control over the json names and values inside the object. They will be in the format below. I have not been able to get the tree to load. Is there a specific format the json needs to be in, in order to load properly?
Here is the JSON
{
"root":true,
"topNode": {
"containerId":"1",
"children":[
{
"containerId":"2",
"children":[
],
"root":false
},
{
"containerId":"3",
"children":[
{
"containerId":"4",
"children":[
],
"root":false
}
],
"root":false
},
{
"containerId":"5",
"children":[
{
"containerId":"6",
"children":[
],
"root":false
},
{
"containerId":"7",
"children":[
],
"root":false
}
],
"root":false
}
],
"root":true
}
}
Here is the Javascript:
$(function(){
$("#treeView").dynatree({
initAjax: {
url: "/myURL",
},
});
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用标准 jQuery
$.json()
或$.ajax
读取数据,然后处理接收到的 JSON,例如使用dataFilter
> 钩子。作为替代方案,您可以实现 dynatree 的(尚未记录)
postProcess(data, dataType)
回调。You could read your data with standard jQuery
$.json()
or$.ajax
, and then process the received JSON, for example using thedataFilter
hook.As an alternative you could implement dynatree's (yet undocumented)
postProcess(data, dataType)
callback.