树刷新问题

yuanye5188 2009-02-27

想实现这样的功能树:

可折叠的布局 (左侧树功能区)--- layout: "accordion",

【动态读取菜单 1   刷新

【动态读取菜单 2   刷新

【动态读取菜单 3   刷新

【动态读取菜单 4   刷新】.....

 

折叠菜单全部是后台读取生成,页面不知道有多少个折叠,点击每个折叠则里面是相应的菜单树,点击刷新则会tree.root.reload()本折叠区的树,和下面结构类似

【动态读取菜单 1   刷新

       根

        |- 菜单 1

        |- 菜单 2

         ..... 

【动态读取菜单 2   刷新

【动态读取菜单 3   刷新

【动态读取菜单 4   刷新】.....

 

目前上述功能已经实现,可每次点击刷新时(不管是哪个折叠区的刷新按钮),刷新的总是最后一个折叠区的树菜单(上面的红色标注),本人刚接触EXT不长时间,请高人相助,关键js如下:

MenuPanel = function(){
    MenuPanel.superclass.constructor.call(this, {
        id: 'menu',
        region: 'west',
        title: "菜单",
        split: true,
        collapseMode: 'mini',
        width: 200,
        minSize: 125,
        maxSize: 300,
        collapsible: true,
        margins: '0 0 -1 1',
        layout: "accordion",
        defaults: {
            autoScroll: true,
            border: false
        },
        items: getItems()
    });

};

function getItems(){
    var items = new Array();
    var re = doActionFromAJAX('system/resource!getResourceItems.action', 'parent=0', true, true);
    var result = Ext.util.JSON.decode(re)
    //alert(result.toJSONString());
    var name_ = '';
    for (var i = 0; i < result.result.length; i++) {
        name_ = 'system_menu1'+i;
        items[i] = {
            title: result.result[i].r_name,
            iconCls: "icon-sys",
            items: [new Ext.tree.TreePanel({
                id:name_,
                useArrows:false,//使用箭头形式
                autoScroll:true,
                animate:true,
                enableDD:false,
                border: false,
                containerScroll: true,
                rootVisible: true,
                root: new Ext.tree.AsyncTreeNode({
                   text: result.result[i].r_name,
                   draggable: false,//是否可以拖拽
                   expanded: true,
                   id:result.result[i].r_id
                }),
                loader:new Ext.tree.TreeLoader({
                   dataUrl:path+'/system/resource!getTree.action'
                }),
                listeners: {
                   "click": function(node){
                       if(node.attributes.leaf){
                            main.openUrl(path+node.attributes.link, 'tab-'+node.id, node.text);
                       }
                   }
                }
           })],
           tools:[{
               id:'refresh',
               qtip:'刷新',
               handler:function(){
                   Ext.getCmp(name_).root.reload();
               }
           }]
        };
    }
   
    return items;
}

yuanye5188 2009-02-27
就没人帮帮我吗....郁闷
zhaofei1394 2009-03-03
var deptPanel = new Ext.Panel({ 
     title: '部门管理',
     autoScroll:true, 
     iconCls:'deptLabelName',
                        tools:[{
                            id:'refresh',
                            on:{
                                click: function(){
                                    var treedept = Ext.getCmp('deptTree');
                                    treedept.body.mask('Loading', 'x-mask-loading');
                                    treedept.root.reload();
                                    treedept.root.collapse(true, false);
                                    setTimeout(function(){ // mimic a server call
                                        treedept.body.unmask();
                                        treedept.root.expand();
                                    }, 1000);
                                }
                            }
                        }],
     contentEl: "deptPanel"
});
我是这样实现树的刷新的,希望对你有帮助
yuanye5188 2009-03-10
谢了,问题还是不能解决,期待中...
niuren_hua 2012-07-16
yuanye5188 写道
谢了,问题还是不能解决,期待中...

你的id相同了
Global site tag (gtag.js) - Google Analytics