【问题标题】:extjs 3.4 unable to access children of a node in a treeextjs 3.4 无法访问树中节点的子节点
【发布时间】:2013-12-10 15:15:20
【问题描述】:

我正在尝试使用 javascript、JSON 数据和 extjs 构建一种文件浏览器类型的树结构。我使用的 JSON 数据是

[
{
    "id": "Folder One",
    "text": "<font color=\"#000000\" size=\"2\"><b>Folder One</b></font>",
    "children": [
        {
            "id": "111",
            "text": "<font color=\"#000000\" size=\"2\"><b>File1 (111)</b></font>",
            "leaf": true
        }
    ]
},
{
    "id": "Folder Two",
    "text": "<font color=\"#000000\" size=\"2\"><b>Folder Two</b></font>",
    "children": [
        {
            "id": "111",
            "text": "<font color=\"#000000\" size=\"2\"><b>File1 (111)</b></font>",
            "leaf": true
        }
    ]
}
]

此 JSON 通过以下代码传递给 Asynctreenode:

var   fileList =   JSON.parse(resp);
    //alert("fileList from Server : "+JSON.stringify(fileList));

asyncTree = new Ext.tree.AsyncTreeNode({
            id:'asyncTree',
            expanded: true,
            border : false,
            children: [
                       {
                           "id":"asyncTreeChild",
                           "text":"<font color=#000000 size=2><b>My Computer</b></font>",
                           children:fileList
                        }
                       ]
        });

问题是当节点“文件夹一”下的文件不可点击时。相反,选择直接移动到“文件夹二”节点下的文件。节点“文件夹一”和“文件夹二”也返回正确的路径。它只是“文件夹一”下不可访问的文件。有什么想法吗?

【问题讨论】:

    标签: javascript json extjs treepanel


    【解决方案1】:

    我发现了问题所在。孩子的 id 属性相同,这导致了问题。将其更改为不同的值(从 111 更改为其他值)解决了这个问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-07-26
      • 1970-01-01
      • 1970-01-01
      • 2013-05-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多