六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 55|回复: 0

如何动态加载accordion布局的panel呢?

[复制链接]

升级  20%

2

主题

2

主题

2

主题

童生

Rank: 1

积分
10
 楼主| 发表于 2013-1-29 12:53:37 | 显示全部楼层 |阅读模式
这种效果是可以实现的,只需要监听一个事件,然后通过AJAX取得JSON格式的菜单项目信息,然后动态的对这个TreePanel添加就行了,我试了效果已出来,代码如下:
......
        this.accPanel = new Ext.Panel({
                region:'west',
baseCls:'x-panel',
                split:true,
title:'系统菜单',
collapsible :true,
layoutConfig:{
animate:true
},
               width: 210,
                layout:'accordion',
listeners:{'beforerender':function(){
alert('hi,,,,,');
Ext.Ajax.request({
   url: 'scripts/addModel.php?action=0',
   success: function(request){
var mydata=Ext.decode(request.responseText);
for(var i=0;i<mydata.total;i++){
var id = mydata.root[i].id;
var tmp = new Ext.Panel({
id:id,
region:'west',
title:mydata.root[i].modelName,
baseCls:'x-panel',
border:false,
autoWidth:true
});
//this.add(this.id)
//alert(mydata.root[i].id);
alert(this.title);
this.add(tmp);
this.doLayout(true);
//this.ownerCt.ownerCt.add(id)
//alert();
//this.ownerCt.ownerCt.add(this.id);
}
//return true;
   },
   scope:this,
   failure: function(){
alert('error');
   }
});
}},
                items: [this.item1,this.item2]
});
        var tab =  new Ext.Panel({
            title: '系统介绍',   
            id: 'docs',
            bodyStyle:'padding:10px',
            autoLoad: 'docs.html',
            layout: 'fit'  
        });
......
这是我现在做的一个系统里面用到的一部分代码,希望能帮上你的忙.
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表