1

In ExtJS 4.1 I'm selecting a TreePanel node by its ID like this:

var n = myTreePanel.getStore().getNodeById(id);
myTreePanel.selectPath(n.getPath());

.. which seems like a lot of typing for such a simple operation. Is there a more concise way?

1 Answer 1

3

I don't believe there's a more concise way of writing that code that's built-in to the framework. You can always just write your own method and add it to the Tree class.

Ext.tree.Panel.addMembers({
    selectPathById: function(id){
        var me = this,
            node = me.getStore().getNodeById(id);
        if(node){
            me.selectPath(node.getPath());
        }
    }
});

/* Later, in your own code */
myTreePanel.selectPathById(id);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.