Extjs4 如何阻止extjs treepanel无限加载?

Extjs4 如何阻止extjs treepanel无限加载?,extjs4,treepanel,Extjs4,Treepanel,最后,在努力使用extjs树面板、树存储和构建定制阅读器来读取和转换pentaho数据2周后,我成功地将pentaho数据加载到extjs的treepanel中 现在,我的树面板正在无限地加载相同的数据。 Treepanel的外观如下所示: 我的部分json数据如下所示: { {name: 'US', candidateCount: 3, children: []}, {name: 'India', candidateCount: 922, children: [

最后,在努力使用extjs树面板、树存储和构建定制阅读器来读取和转换pentaho数据2周后,我成功地将pentaho数据加载到extjs的treepanel中

现在,我的树面板正在无限地加载相同的数据。 Treepanel的外观如下所示:

我的部分json数据如下所示:

{
    {name: 'US', candidateCount: 3, children: []},
    {name: 'India', candidateCount: 922, children: [
       {name: 'Goa', candidateCount:124, children: []},
       {name: 'Maharashtra', candidateCount: 43, children: [
             {name: 'Pune', candidateCount: 3},
             {name: 'Mumbai', candidateCount: 33},
             {name: 'Kolhapur', candidateCount: 4},
             {name: 'XXX', candidateCount: 3},
        ]}
     ]},
    {name: 'UK', candidateCount: 1, children: []},
}
如上图所示,在扩展印度节点后,它再次加载了国家级数据,即国家名称美国、英国、印度、英国。实际上,我想展示邦级数据,比如果阿马哈拉施特拉邦的数据。而不是树面板再次加载相同的数据

如何避免这种行为?我已经将美国、英国和印度节点的叶属性设置为false

我尝试将Expanded属性设置为true,但treepanel一次又一次地加载相同的节点,我的浏览器选项卡被挂起

请让我知道如何避免这种情况?我希望树面板只加载一次数据

编辑-此问题的解决方案


我解决了这个问题,在store的append事件上添加了listener,然后为我想要成为leaf的节点将leaf值设置为true。加载树可能会很麻烦。在这些节点上尝试设置loaded:true。在开始四处单击之前,是否正确加载了树?

加载树可能会很麻烦。在这些节点上尝试设置loaded:true。在开始四处单击之前,树是否已正确加载?

将数据项设置为:

{
    ...
    leaf: true
}
将停止。将数据项设置为:

{
    ...
    leaf: true
}

我的treepanel和JSON数据也有同样的问题。我的树顶看起来像这样:

proxy: {
        type: 'ajax',
        url: 'urlJson',

        reader: {
            type: 'json',
            root: 'instanceList',
            successProperty: 'success'
        }
    },

    root:{
        text: 'Root',
        expanded: true
    }
还有JSON

{
    "instanceList": [
        {
            "text": "Parent 1",
            "instanceList": [
                {
                    "class": "testing",
                    "id": 3,
                    "leaf": true,
                    "text": "Child 1"
                }
            ]
        },
        {
            "text": "Parent 2",
            "instanceList": [
                {
                    "class": "testing",
                    "id": 2,
                    "leaf": true,
                    "text": "Child 2"
                },
                {
                    "class": "testing",
                    "id": 1,
                    "leaf": true,
                    "text": "Child 3"
                }
            ]
        }
    ],
    "instanceTotal": 1,
    "success": true
}

我为instanceList更改了children,我的treepanel停止了无限循环,所以我想如果您为children更改名称?

我的treepanel和JSON数据也有同样的问题。我的树顶看起来像这样:

proxy: {
        type: 'ajax',
        url: 'urlJson',

        reader: {
            type: 'json',
            root: 'instanceList',
            successProperty: 'success'
        }
    },

    root:{
        text: 'Root',
        expanded: true
    }
还有JSON

{
    "instanceList": [
        {
            "text": "Parent 1",
            "instanceList": [
                {
                    "class": "testing",
                    "id": 3,
                    "leaf": true,
                    "text": "Child 1"
                }
            ]
        },
        {
            "text": "Parent 2",
            "instanceList": [
                {
                    "class": "testing",
                    "id": 2,
                    "leaf": true,
                    "text": "Child 2"
                },
                {
                    "class": "testing",
                    "id": 1,
                    "leaf": true,
                    "text": "Child 3"
                }
            ]
        }
    ],
    "instanceTotal": 1,
    "success": true
}
我为instanceList更改了children,我的treepanel停止了无限循环,所以我想如果您更改children的名称?

请确保所有没有任何子级的父级都将leaf设置为true或true 有一个空的子节点

所有子节点的叶都设置为true,正如Asken所提到的,请确保所有没有子节点的父节点的叶都设置为true或true 有一个空的子节点


所有子节点的leaf都设置为true,正如Asken所说,如果在proxy custom rootProperty中设置为'instanceList',则必须将json中的所有子节点都更改为该属性,即'instanceList'。这是我的解决方案。

正如Edd所说,如果您在代理自定义根属性中设置:'instanceList',您必须将json中的所有子级更改为该属性,即'instanceList'。这是我的解决办法。

在我看来,任何孩子都会成为其家属的根。因此,根属性和子属性必须具有相同的名称。我很高兴我找到了这个脚印。它救了我的命,因为无休止地重新装填圣诞树,我差点开枪自杀。在我看来,任何一个孩子都会成为其家属的根。因此,根属性和子属性必须具有相同的名称。我很高兴我找到了这个脚印。它救了我的命,因为无休止地重新加载这棵树,我正要开枪自杀

嗨,你能分享你的商店代码吗?我也有同样的行为。谢谢你能分享你的商店代码吗?我也有同样的行为。谢谢