首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网络技术 > 网络基础 >

main page js 二

2012-10-29 
main page js 2findNodeById:function(id){var node,trees this.findByType(treepanel,true)Ext.each

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

热点排行