ext的border布局,把界面分成左中右三个板块(要做超级复杂的布局,可以参考ext的官方demo)。
在Ext.onReady(function() { }之间的主要代码如下:
//////////////整体页面布局////////////////////
var viewport = new Ext.Viewport({
layout:'border',
border:false,
items:[{
xtype:'panel',
region:'west',
layout:'fit',
width:document.body.clientWidth*0.15,
items:[moudletreePanel],
},{
xtype:'panel',
region:'center',
layout:'fit',
width:document.body.clientWidth*0.6,
items:[datagrid],
},{
xtype:'panel',
region:'east',
id:'operationSet',
layout:'fit',
hidden:true,
width:document.body.clientWidth*0.25,
items:[opergrid]
}
]
});可见,三个panel板块里面的items,其值也是panel,注意,这三个面板可以设置id值,我在右边板块(east)设了id为operationSet,对他进行显示/隐藏。当然,title属性也是可以加上去的。测试时分别把items属性去掉,换成html属性,如
html: '<span><a href="#" onclick="show();">show</a></span>'这样就有个响应按钮了,当然,有了show()怎能没有hide(),所以html的属性值可以改为:
<span>
<a href="#" onclick="show();">show</a> <br> <a href="#" onclick="hide();">hide</a>
</span>接着,要写show、hide的公共函数,注意了,一定要是公共函数,也就是说,写在Ext.onReady(function() {}的外面。函数如下
function hide(){
Ext.getCmp("operationSet").hide();
Ext.getCmp("operationSet").ownerCt.doLayout();//刷新
}
function show(){
Ext.getCmp("operationSet").show();
Ext.getCmp("operationSet").ownerCt.doLayout();//刷新
}备注:本实例在ext4上可以运行,应该可以向下版本兼容。

本文介绍了如何利用Ext.js的边框布局特性,将界面划分为左、中、右三个板块,并通过代码示例展示了如何在每个板块中嵌套面板,实现复杂的布局结构。此外,文章还提供了隐藏与显示右侧板块的交互操作,以及展示代码的兼容性。
3006

被折叠的 条评论
为什么被折叠?



