Question

I'm trying to traverse all of the nodes in my tree panel. The problem is that if I don't expand a node before calling node.eachChild(), the node thinks that it doesn't have any children. (Even if it does)

If you look at my jsfiddle, click the Traverse button without expanding any nodes and it will only show the root node + its three child nodes. Now if you go back and expand all the child nodes, close them then click the button again it shows you all of the nodes.

http://jsfiddle.net/sQ97F/

How can I make my tree panel load all of the child nodes so that it goes through all the children right after onReady?

Note: I also don't want the nodes expanded in the onLoad() so hacking it up to use tree.getRootNode().expand() isn't a good solution.

Was it helpful?

Solution

Adding loader: new Ext.tree.TreeLoader({ preloadChildren: true }) to the TreePanel config should work.

new Ext.tree.TreePanel({
    renderTo: Ext.getBody(),

    loader: new Ext.tree.TreeLoader({ preloadChildren: true }), //New Config


    id: 'mainTree',
    title: 'Packages',
    useArrows: true,
    autoScroll: true,
    containerScroll: true,
    frame: true,
    rootVisible: false,
    root: rootNode,
    buttons: [traverse]
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top