views:

592

answers:

4

Hi,

I'm looking for a way to scroll to a specific element in a Tree. Any idea how to do this ?

A: 

It isn't directly related to extJs, but you could get the DOM element you want in your tree and use scrollTo to get to it.

Valentin Rocher
A: 

Try this in your node click event handler:

node.getUI().getIconEl().scrollIntoView(node.getOwnerTree(), false);
Jonathan Julian
Hi ! I've not tried it, but it may work. See my answer to see what I've done :)
Olivier Pons
A: 

I just had to call n.select(); but I had to do it in the right place :)

I made a TreeLoader, and linked it to my tree. In its event load (which means 'when all is downloaded', I would have called it afterload...), I read all the nodes and depending on their id I act consequently:

var LasTreeLoader = new Ext.tree.TreeLoader({
    dataUrl: 'json/las.php',
    listeners: {
        load: function(loader,n,response) {
        console.log('datas downloaded');
        n.eachChild(
            function(n) {
                if ((n.id=='las/2007') ||
                    (n.id=='las/2007/08') ||
                    (n.id=='las/2007/08/29')) {
                    n.expand(false,false);
                }
                if (n.id=='las/2007/08/29/21_14_04') {
                    n.select();
                }
            });
        }
    }
});
Olivier Pons
A: 

var path = tree.getSelectionModel().getSelectedNode().getPath('id');

//reload data,

tree.getLoader().load(tree.getRootNode(),function(treeNode){

//expand path and select node

tree.expandPath(path,'id',function(bSucess,oLastNode){

tree.getSelectionModel().select(oLastNode);

});

},this);

TZ25