Question

I'm not too familiar with ExtJS, but am working on a project that uses it.

We are making use of a TreePanel with a TreeLoader that loads all node data from the server in one call. We have an event in which I need to access the attributes of every node in the tree. The way I am doing this is using the TreePanel's getNodeById method. The problem is that the tree panel seems to lazily load nodes and will not be able to retrieve a node with getNodeById unless the node has already been loaded.

Is there any way to force all nodes to be loaded? The closest I've come is by using the preloadChildren attribute on the TreeLoader, but this still only loads when the parent node containing children is loaded.

Was it helpful?

Solution

If you want to be able to access all the nodes, you must load the complete tree structure on the first call.

The JSON response on the first call should include all the tree nodes. For example:

[{
    id: 1,
    text: 'A leaf Node',
    leaf: true
},{
    id: 2,
    text: 'A folder Node',
    children: [{
        id: 3,
        text: 'A child Node',
        leaf: true
    }]

}]

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top