ext2.0中layout布局(6)

1.ExtJS一共包含十种布局,常用的布局有border、column、fit、form、card、tabel等布局

column布局:

Ext.onReady(function(){
	new Ext.Panel({
		renderTo:"hello",
		width:400,
		height:200,
		layout:"column",
		items:[{columnWidth:.5,
		title:"面板1"},
		{columnWidth:.5,
		title:"面板2"}]
	});
});

Ext.onReady(function(){
	new Ext.Panel({
		renderTo:"hello",
		title:"容器组件",
		layout:"column",
		width:500,
		height:100,
		items:[
			{title:"列1",width:100},
			{title:"列2",width:200},
			{title:"列3",width:100},
			{title:"列4"}
		   ]
		}
	);
});
Ext.onReady(function(){
	new Ext.Panel({
		renderTo:"hello",
		title:"容器组件",
		layout:"column",
		width:500,
		height:100,
		items:[
			{title:"列1",columnWidth:.2},
			{title:"列2",columnWidth:.3},
			{title:"列3",columnWidth:.3},
			{title:"列4",columnWidth:.2}
		  ]
		});
});

Ext.onReady(function(){
	new Ext.Panel({
		renderTo:"hello",
		title:"容器组件",
		layout:"column",
		width:500,
		height:100,
		items:[{title:"列1",width:200},
		{title:"列2",columnWidth:.3},
		{title:"列3",columnWidth:.3},
		{title:"列4",columnWidth:.4}
		] 
	});
});


border布局:

Ext.onReady(function(){
	new Ext.Viewport({
		layout:"border",
		items:[
			{region:"north",height:50,title:"顶部面板"},
			{region:"south",height:50,title:"底部面板"},
			{region:"center",title:"中央面板"},
			{region:"west",width:100,title:"左边面板"},
			{region:"east",width:100,title:"右边面板"}
		]
	});
});

Fit 布局:

Ext.onReady(function(){
	new Ext.Panel({
		renderTo:"hello",
		title:"容器组件",
		layout:"fit",
		width:500,
		height:100,
		items:[{title:"子元素",html:"这是子元素中的内容"}
		] 
	});
});

比较上诉和下面的代码的效果:

Ext.onReady(function(){
	new Ext.Panel({
		renderTo:"hello",
		title:"容器组件",		
		width:500,
		height:200,
		items:[
		{title:"子元素",html:"这是子元素中的内容"},
		{title:"子元素22",html:"2222222222222222"}
		] 
	});
});


 f orm布局:

Form 布局由类Ext.layout.FormLayout 定义,名称为form,是一种专门用于管理表单中输入字段的布局,

Ext.onReady(function(){
	new Ext.Panel({
		renderTo:"hello",
		title:"容器组件",
		width:300,
		layout:"form",
		hideLabels:false,
		labelAlign:"right",
		height:120,
		defaultType: 'textfield',
		items:[
		{fieldLabel:"请输入姓名",name:"name"},
		{fieldLabel:"请输入地址",name:"address"},
		{fieldLabel:"请输入电话",name:"tel"}
		] 
	});
});
在父容器中还通过hideLabels、labelAlign 等配置属性来定义了是否隐藏标签、标签对齐方式等


Accordion 布局

Ext.onReady(function(){
	new Ext.Panel({
		renderTo:"hello",
		title:"容器组件",
		width:500,
		height:200,
		layout:"accordion",
		layoutConfig: {
		animate: true
		},
		items:[
			{title:"子元素1",html:"这是子元素1中的内容"},
			{title:"子元素2",html:"这是子元素2中的内容"},
			{title:"子元素3",html:"这是子元素3中的内容"}
		]
	});
});


Table 布局

Ext.onReady(function(){
	var panel=new Ext.Panel({
		renderTo:"hello",
		title:"容器组件",
		width:500,
		height:200,
		layout:"table",
		layoutConfig: {
		columns: 3
		},
		items:[
			{title:"子元素1",html:"这是子元素1中的内容",rowspan:2,height:100},
			{title:"子元素2",html:"这是子元素2中的内容",colspan:2},
			{title:"子元素3",html:"这是子元素3中的内容"},
			{title:"子元素4",html:"这是子元素4中的内容"}
		] 
	});
});








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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值