1.column Layout 列布局

在子元素中指定使用columnWidth或width来指定子元素所占的列宽度。columnWidth表示使用百分比的形式指定列宽度。width则是使用绝对象素的方式指定列宽度,在实际应用中可以混合使用两种方式。

Ext.onReady(function(){
var window = new Ext.Window({
layout: "column",
title: "Hello World",
id: "helloWorldWindow",
bodyStyle: "padding:10px;",
width: 550,
height: 300,
x: 100,
y: 100,
items: [
{
columnWidth: .6,
baseCls: "x-plain",
frame: true,
layout: "form",
bodyStyle: "padding:5px;",
items: [
{xtype: "textfield", fieldLabel: "UserName"},
{xtype: "textfield", fieldLabel: "Age"}
]
},
{
columnWidth: .3,
baseCls: "x-plain",
bodyStyle: "padding:5px;",
items: [
{xtype: "textarea"}
]
},
{
columnWidth: .1,
baseCls: "x-plain",
bodyStyle: "padding:5px;",
layout: "form",
items: [
{
xtype: "button",
text: "Ok",
handler: function() {
alert("OK");
}
},
{
xtype: "button",
text: "Cancel",
handler: function() {
alert("Cancel");
}
}
]
}
]
});

window.render(Ext.getDom("tt"));
window.show();
});

2.fit Layout

Fit布局,子元素将自动填满整个父容器(对元素设置宽度无效),如果容器组件中有多个子元素,则只会显示第一个子元素。
Ext.onReady(
function(){
var win = new Ext.Window({
title: "Hello World",
renderTo: Ext.getDom("tt"),
width: 400,
height: 250,
x: 150,
y: 50,
layout: "fit",
items: [
{xtype:"panel", title:"O"},
{xtype:"panel", title:"K"}
]
});

win.show();
}
);

3. border Layout

一、Border布局由类Ext.layout.BorderLayout定义,布局名称为border。该布局把容器分成东南西北中五个区域,分别由east,south, west,north, cente来表示,在往容器中添加子元素的时候,我们只需要指定这些子元素所在的位置,Border布局会自动把子元素放到布局指定的位置。
Ext.onReady(
function() {
new Ext.Viewport({
layout:"border",
items:[
{
region:"north",
height:80,
xtype: "label",
//style: "border: 1px solid red;padding:1px;",
frame: true,
text: "cdred.net study club"
},
{
region:"south",
height:20,
xtype:'label',
text:'Status show zone..'
},
{
region:"center",
title:"中央面板"
},
{
region:"west",
width:200,
title:"系统栏目",
collapsible: true
},
{
region:"east",
width:150,
collapsed: true,
collapsible: true,
title:"在线好友"
}

]

});
}
);

4.accordion Layout
Accordion布局由类Ext.layout.Accordion定义,表示可折叠的布局,点击每一个子元素的头部名称或右边的按钮,则会展开该面板,并收缩其它已经展开的面板。
layoutConfig:true表示在执行展开折叠时启动动画效果,默认值为false。

** 注意如果你是用 panel之类的 必须拥有 title:'' 属性

Ext.onReady(function(){
var panel = new Ext.Panel({
title:"人员信息",
renderTo:Ext.getDom("tt"),
frame:true,
width:250,
height:300,
layout:"accordion",
layoutConfig: {
animate: true
},
items:[
{xtype:"panel", title:"O", html:"这是子元素1中的内容"},
{xtype:"panel", title:"K", html:"这是子元素2中的内容"},
{xtype:"panel", title:"L", html:"这是子元素3中的内容"}
]
});
});

5 form Layout

Form布局由类Ext.layout.FormLayout定义,名称为form,是一种专门用于管理表单中输入字段的布局,这种布局主要用于在程序中创建表单字段或表单元素等使用。

hideLabels:tru表示隐藏标签,默认为false。
labelAlign:标签队齐方式left、right、center,默认为left。

在实际应用中,Ext.form.FormPanel这个类默认布局使用的是Form布局,因此我们直接使用FormPanel即可。

Ext.onReady(
function() {
var panel = new Ext.Panel({
layout:"form",
title: "HelloWorld",
renderTo:Ext.getDom("tt"),
width: 400,
height:250,
frame: true,
hideLabel: true,
collapsible: true,
bodyStyle: "padding:20px;",
defaultType:"textfield",
items:[
{fieldLabel:"Hello"},
{fieldLabel:"World"}
]
});
}
);

6 table Layout

Table布局由类Ext.layout.TableLayout定义,类以于html中的table,可以对行或列进行合并。
layoutConfig使用columns指定父容器分成3列,
rowspan合并行数目。
colspan合并列数目。
Ext.onReady(exe);

function exe() {
var panel = new Ext.Panel({
title: "Hello World",
layout: "table",
width: 500,
height: 300,
bodyStyle:'padding:20px;',
layoutConfig: {
columns: 3
},
items: [
{xtype:"panel", title:"hello", html:"hello context", rowspan:2, height: 100},
{xtype:"panel", title:"world", html:"world context", colspan:2},
{xtype:"panel", title:"cheng", html:"cheng context"},
{xtype:"panel", title:"du", html:"du context"}
]
});

panel.render(Ext.getDom("tt"));
}

7 card Layout

Ext.onReady(function() {
var i = 0;
var navHandler = function(direction){
i += direction;
Ext.getCmp("card").getLayout().setActiveItem(i);
if (i == 2) {
Ext.getCmp("move-next").setDisabled(true);
} else if (i == 0) {
Ext.getCmp("move-prev").setDisabled(true);
} else {
Ext.getCmp("move-next").setDisabled(false);
Ext.getCmp("move-prev").setDisabled(false);
}

};
var card = new Ext.Panel({
id: "card",
title : 'Example Wizard',
layout : 'card',
activeItem : 0,
bodyStyle : 'padding:15px',
defaults : {
border : false
},

bbar : [{
id : 'move-prev',
text : 'Back',
handler : navHandler.createDelegate(this, [-1]),
disabled : true
}, '->',
{
id : 'move-next',
text : 'Next',
handler : navHandler.createDelegate(this, [1])
}],

items : [{
id : 'card-0',
html : '<h1>Welcome to the Wizard!</h1><p>Step 1 of 3</p>'
}, {
id : 'card-1',
html : '<p>Step 2 of 3</p>'
}, {
id : 'card-2',
html : '<h1>Congratulations!</h1><p>Step 3 of 3 - Complete</p>'
}]
});
card.render(Ext.getDom("tt"));
});

8 absolute Layout

Ext.onReady(exe);

function exe() {
var form = new Ext.form.FormPanel({
title : 'Absolute Layout',
frame : true,
layout : 'absolute',
x: 100,
y: 40,
height: 500,
layoutConfig : {
extraCls : 'x-abs-layout-item'
},
defaultType : 'textfield',
items : [{
x : 0,
y : 5,
xtype : 'label',
text : 'Send To:'
}, {
x : 60,
y : 0,
name : 'to',
anchor : '100%'

}, {
x : 0,
y : 35,
xtype : 'label',
text : 'Subject:'
}, {
x : 60,
y : 30,
name : 'subject',
anchor : '100%'

}, {
x : 0,
y : 60,
xtype : 'textarea',
name : 'msg',
anchor : '100% 100%'

}]
});

form.render(Ext.getDom("tt"));
}

转载于:https://www.cnblogs.com/yqin/archive/2010/09/06/1819671.html

Extjs layout 总结相关推荐

  1. extjs给panel添加滚动条_ExtJs Panel 滚动条设置

    设置autoscroll:true同时出现横向和纵向滚动条. 不要设置autoscroll属性,或者autoscroll:false,然后设置bodyStyle : 'overflow-x:hidde ...

  2. 【ExtJS】 布局Layout

    布局用于定义容器如何组织内部子元素和控制子元素的大小. ExtJS中有两种类型的布局:Container容器类布局与Component组件类布局. Containter容器类布局:负责容器内容Extj ...

  3. ExtJS中layout的12种布局风格

    总览 extjs的容器组件都可以设置它的显示风格,它的有效值有 1. absolute,2. accordion, 3. anchor, 4. border, 5. card, 6. column, ...

  4. ExtJS 4.2心得和总结:布局系统详解(Ext.layout.container)

    在ExtJS 4.2中,提供了十几种布局,我们可以在api中看到如下图: 我们可以看到很多,比如Accordion.Border.Column.Fit.Form等.下面我们来看一下具体的用法. 下面是 ...

  5. ExtJS中layout布局详解

    layout中有absolute,anchor,border,accordion,card,form,table,column,fit这几种,现一一举例: 1.absolute根据字面意思就知道,是根 ...

  6. ExtJs 备忘录(3)—— Form表单(三) [ 数据验证 ]

    正文 一.资料 1.1. 表单提示的方式设置,如: Ext.form.Field.prototype.msgTarget='side' 该设置为枚举值:'qtip','side','title','u ...

  7. ExtJs中column与form布局的再次领悟

    前段时间转了一篇有关于ExtJs中column与form的布局问题(可以参考这篇文章http://sucre.blog.51cto.com/1084905/884279 ),今天在设计页面时又用到了这 ...

  8. ExtJS 4.2 教程-08:布局系统详解

    ExtJS 4.2 系列教程导航目录: ExtJS 4.2 教程-01:Hello ExtJS ExtJS 4.2 教程-02:bootstrap.js 工作方式 ExtJS 4.2 教程-03:使用 ...

  9. ExtJs自学教程(1):一切从API開始

    题 记 该系列文章不側重全方位的去介绍ExtJs的使用,仅仅是側重于解决ExtJs问题的思考方法.写的人不用长篇大论,学的人则可以自立更生.l   学习的人仅仅要有一些CSS的javascript的基 ...

最新文章

  1. swift中字符串截取方法(substring)
  2. 微信公众平台消息接口开发(13)多语种互译
  3. 《构建之法》第6 - 7章
  4. #中regex的命名空间_Python命名空间实例解析
  5. 从零开始搭建系统1.1——CentOs安装
  6. 18-爬虫之scrapy框架请求传参实现的深度爬取(全站爬取)05
  7. 一篇文章教会你创建vue项目和使用vue.js实现数据增删改查
  8. AMF(Action Message Format)其它语言对象转ActionScript对象[转]
  9. 关于 SAP Spartacus SSR 服务器返回的响应是否应该被缓存的问题
  10. 如何查看kafka每个话题一共分了几个分区_如何决定kafka集群中话题的分区的数量...
  11. java中Jackson_java 中的好东西 jackson
  12. 人工智能知识全面讲解:最简单的神经元模型
  13. linux命令get命令使用,Linux apt-get命令使用方法
  14. 网易邮箱实名操作流程
  15. 设置浏览器为单进程模式
  16. Ubuntu解决键盘错乱与图形化切换
  17. 网页布局中的 px,em,rem,pt
  18. FT2000+下40G网卡性能优化
  19. 各种颜色的英文表述,以及RGB代码
  20. Linux erlang 源码编译安装

热门文章

  1. 搜索c盘大文件_硬核干货,如何给c盘“减肥”?
  2. 手机信令数据怎么获得_手机信令数据辅助下的张江科学城职住分析及对策 | 上海城市规划...
  3. detectmultiscale函数参数含义_OpenCV人脸识别--detectMultiScale函数
  4. docker中使用idea部署运行项目(项目以镜像方式运行)
  5. ELK快速搭建日志平台(基于7.9.3)
  6. R语言作图之ggplot2初识(1)
  7. matlab求方程实根,简单迭代法求方程根的MATLAB程序
  8. 6. 吴恩达机器学习课程-作业6-SVM
  9. python得安什么安装包_初学 Python 需要安装哪些软件?
  10. pypy mysql 兼容_PyPy运行Django+MySQL简单教程