extjs4-----panel的accordion布局以及treePanel导航

如何创建一个accordion布局的panel?

官方例子

Ext.create('Ext.panel.Panel', {
    title: 'Accordion Layout',
    width: 300,
    height: 300,
    defaults: {
        // applied to each contained panel
        bodyStyle: 'padding:15px'
    },
    layout: {
        // layout-specific configs go here
        type: 'accordion',
        titleCollapse: false,
        animate: true,
        activeOnTop: true
    },
    items: [{
        title: 'Panel 1',
        html: 'Panel content!'
    },{
        title: 'Panel 2',
        html: 'Panel content!'
    },{
        title: 'Panel 3',
        html: 'Panel content!'
    }],
    renderTo: Ext.getBody()
});


后台获取数据,创建导航树,

var store = Ext.create('Ext.data.TreeStore', {
		//The store will automatically create a Ext.data.Model with these fields
		//For anything more complicated, such as specifying a particular id property or associations,
		//a Ext.data.Model should be defined and specified for the model config.
		fields:['text','leaf','url'], 
		proxy : {
			type:'ajax',  
        	//url:'http://localhost:8080/testextjs/servlet/treeServlet',  
			url:url,
        	reader:{  
            	type:'json',  
            	root:'trees'  
        	}
		},
	    
	    autoLoad:true
	});
	
	var treepanel = Ext.create('Ext.tree.Panel', {
		title: 'Panel 1',
	    store: store,
	    rootVisible: false,
	   	listeners: {
	   		itemclick:function(tree,record,item,index,e,options) {
	   			if (record.get('leaf')) {
	   				var url = record.get('url');
	   				Ext.getCmp('centerFrame').body.update("<iframe src='"+url+"' width='100%' height='100%' frameborder='0'></iframe>");
	   			}
	   			
	   		}
	   	}
             
	});


后台传过来的数据格式,注意上边的fields,仔细看一下注释(注释为官方注释)

StringBuilder sbStr = new StringBuilder();
		sbStr.append("{trees:[");
		sbStr.append("{text: '个人生活', leaf: true, url:'pages/txl/txl.jsp'},");
		sbStr.append("{text: '相片管理', leaf: true, url:'pages/txl/txl.jsp'},");
		sbStr.append("{text: '生活管理', leaf: true, url:'pages/txl/txl.jsp'}");
		sbStr.append("]}");

显示效果如下:



示例链接:http://download.csdn.net/detail/scqdscy1994/9698134


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值