ExtJs:树:如何直接滚动到特定元素? [英] ExtJs: Tree: how to scroll directly to a specific element?

查看:22
本文介绍了ExtJs:树:如何直接滚动到特定元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种滚动到树中特定元素的方法.知道怎么做吗?

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

推荐答案

我只需要调用 n.select(); 但我必须在正确的地方这样做 :)

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

我制作了一个 TreeLoader,并将它链接到我的树上.在它的事件 load(这意味着当所有都下载时",我会称它为 afterload...),我读取所有节点并根据它们的 id 我因此采取行动:

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

这篇关于ExtJs:树:如何直接滚动到特定元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆