main page js 2

findNodeById:function(id){
        var node,trees = this.findByType('treepanel',true);
        Ext.each(trees,function(tree){
            node = tree.getNodeById(id);
            return !node;//找到的话返回false
        });
        return node;
    },
    onClick: function(e, t, o){
        if(Ext.fly(t).hasClass('x-tree-ec-icon')){//点击伸展按钮时无视
            return;
        }
        var el,id,node;
        if (el = e.getTarget('.x-tree-node-el', 3,true)) {
            e.stopEvent();
            id = el.getAttributeNS('ext','tree-node-id');
            node = this.findNodeById(id);
            this.fireEvent('click',node);
        }
    },
    creatTreeConfig: function(record){
        var config = {
            xtype: 'treepanel',
            autoScroll: false,

            rootVisible: false,
hideCollapseTool: true,
            title: record.get('name'),
            iconCls: record.get('iconCls'),
            root: {
                nodeType: 'async',
                expanded: true,
                id: record.get('code'),
                children: []
            }
        };

        return config;
    },
    addTreeNode: function(pnodes, record, isLeaf){
        var len = pnodes.length;
        for (var i = len - 1; i >= 0; i--) {
            if (pnodes[i].id != record.get('parentcode')) {
                pnodes.pop();
            }
            else {
                var parent = pnodes[i].children;
                var node = {
                    text: record.get('name'),
                    id: record.get('code'),
                    iconCls: record.get('iconCls'),
                    href: record.get('href'),
                    leaf: isLeaf
                };
                if (!isLeaf) {
                    node.children = [];
                    pnodes.push(node);
                }
                parent.push(node);
                return;
            }
        }
    }
});

你可能感兴趣的:(ext)