ExtJs: Tree: how to scroll directly to a specific element?

后端 未结 5 429
走了就别回头了
走了就别回头了 2021-01-07 08:03

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

5条回答
  •  庸人自扰
    2021-01-07 08:38

    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();
                    }
                });
            }
        }
    });
    

提交回复
热议问题