How to stop extjs treepanel from loading infinitely?

一笑奈何 提交于 2019-12-07 05:32:26

Setting data item to:

{
    ...
    leaf: true
}

will stop it.

I had the same problem with my treepanel and JSON data. My treeStore looks something like this:

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

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

    root:{
        text: 'Root',
        expanded: true
    }

And the 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
}

I changed "children" for "instanceList" and my treepanel stopped doing that infinitely loop, so I guess If you change "name" for "children" ?

Loading trees can be tricking. Try setting loaded: true on those nodes. Before you start clicking around, is the tree properly loaded?

Make sure all parents that do not have any children have "leaf" set to "true" OR have an empty "children" node.

AND all children nodes have "leaf" set to "true" (as already mentioned by Asken)

it seems to me that any child becomes a root to its dependents . So the root property and the children property MUST have the same NAME. I am very happy I found this tread. It saved my life I was about to shoot myself because of endless reloading the tree

As Edd said, if you set in proxy custom rootProperty:'instanceList', you have to change all "children" in json to that property, ie 'instanceList'. It was my solution.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!