Hello all!

Since I couldn't find a way to make a TreePanel remember it's state (i.e. remember which nodes were expanded/collapsed), I figured I would post my solution here.

All I had to do was add the following to my TreePanel configuration:

Code:
    stateEvents : ['collapsenode', 'expandnode'],
    stateId : 'tree-panel-state-id',
    stateful : true,
    getState : function () {
        var nodes = [];
        this.getRootNode().eachChild(function (child) {
            //function to store state of tree recursively
            var storeTreeState = function (node, expandedNodes) {
                if(node.isExpanded() && node.childNodes.length > 0) {
                    expandedNodes.push(node.getPath());
                    node.eachChild(function (child) {
                        storeTreeState(child, expandedNodes);
                    });
                }
            };
            storeTreeState(child, nodes);
        });
            
        return {
            expandedNodes : nodes
        }
    },
    applyState : function (state) {
        var that = this;
        this.getLoader().on('load', function () {
            var nodes = state.expandedNodes;
            for(var i = 0; i < nodes.length; i++) {
                if(typeof nodes[i] != 'undefined') {
                    that.expandPath(nodes[i]);
                }
            }
        });
    }
Any comments/suggestions are more than welcome!

Cheers,
-Roger