准备工作,布置一个最简单的Form,共5个组件,都为textfield。

 Ext.onReady(function(){
Ext.create('Ext.form.Panel', {
width: 500,
title: 'Layout',
     renderTo : 'form',
items: [{
xtype : 'textfield',
fieldLabel : 'edit1',
name : 'edit1',
},{
xtype : 'textfield',
fieldLabel : 'edit2',
name : 'edit1',
},{
xtype : 'textfield',
fieldLabel : 'edit3',
name : 'edit1',
},{
xtype : 'textfield',
fieldLabel : 'edit4',
name : 'edit1',
},{
xtype : 'textfield',
fieldLabel : 'edit5',
name : 'edit1',
}],
     buttons : [{
       text : 'upDate',
       handler : function(){
         //do something...
       }
     }]
});
})

效果:


1、Absolute绝对布局:

  使用标准x,y属性进行x/y坐标定位。

 Ext.create('Ext.form.Panel', {
  title: 'Absolute',
  renderTo: 'absolute',
  width: 500,
  height: 250,
  layout: 'absolute',
  items: [{
  xtype : 'textfield',
   fieldLabel : 'edit1',
  width : 100,
  name : 'edit1',
  x : 10,
y : 10
},{
  xtype : 'textfield',
  fieldLabel : 'edit2',
   width : 160,
  name : 'edit1',
  x : 20,
  y : 40
},{
  xtype : 'textfield',
  fieldLabel : 'edit3',
  width : 60,
  name : 'edit1',
  x : 30,
  y : 70
 },{
  xtype : 'textfield',
   fieldLabel : 'edit4',
  width : 190,
name : 'edit1',
   x : 40,
  y : 100
  },{
    xtype : 'textfield',
    fieldLabel : 'edit5',
    width : 220,
    name : 'edit1',
    x : 50,
    y : 130
  }],
  buttons : [{
    text : 'upDate',
    handler : function() {
    //do something...
    }
  }]
});

效果:

ps:在调试的时候遇到一个情况,如果仅设置宽width而不设置高height的话,会出现“Layout run failed ”错误。不过若是仅设置高而不设置宽,则Form宽填充整个页面,而不会出现错误。


2、accordion手风琴式布局:

注意:只有 Ext的各种Panel和Ext.panel.Panel的子类可以用于这种布局的容器中.

诸如Header、Table、Tool等,子类有:

  Ext.container.ButtonGroup
  Ext.form.Panel
  Ext.menu.Menu
  Ext.panel.Table
  Ext.tab.Panel
  Ext.tip.Tip
  Ext.window.Window
 Ext.create('Ext.form.Panel', {
width: 500,
height: 250,
title: 'Accordion',
renderTo: 'accordion',
layout : 'accordion',
items: [{
title: 'Panel1',
html: 'Panel content!'
},{
itle: 'Panel2',
html: 'Panel content!'
},{
title: 'Panel3',
html: 'Panel content!'
}],
buttons : [{
text : 'open Panel3',
  handler : function() {
Ext.getCmp('Panel3').expand(true);
  }
}]
});

效果:


3、Anchor式布局:

根据父控件宽高,以固定百分比或者固定偏移量来决定子控件的尺寸。

 Ext.create('Ext.form.Panel',{
width: 500,
height: 400,
title: 'Anchor',
renderTo: 'anchor',
layout: 'anchor',
buttonAlign : 'center',
items: [{
    xtype: 'panel',
  title: '75% Width and 20% Height',
   anchor: '75% 20%'
},{
  xtype: 'panel',
  title: 'Offset -300 Width and -200 Height',
anchor: '-300 -200'
},{
xtype: 'panel',
title: 'Offset -200 Width and 40% Height',
anchor: '-250 40%'
}],
buttons : [{
text : 'upDate',
handler : function() {
//do something..
}
}]
});

效果:


4、Auto布局:

 Ext.create('Ext.form.Panel',{
width: 500,
height: 400,
title: 'Auto',
renderTo: 'auto',
layout: 'auto',
buttonAlign : 'center',
margin: '50 150 50 50',
border: true,
items: [{
type: 'panel',
title: 'AutoLayout1',
margin: '10 10 10 10',
border: true,
},{
xtype: 'panel',
title: 'AutoLayout2',
border: true,
margin: '10 10 10 10'
}],
buttons : [{
text : 'upDate',
handler : function() {
//do something..
}
}]
});

效果:



一些常用配置与问题:

1、border 边框设置

  默认为false,边框不可见。true为边框可见。

2、margin 组件页边

  margin 可以是一个数值适用于所有边 或者它可以是每个样式的CSS样式规范, 例如: '10 5 3 10'。

3、buttonAlign 按钮Button位置

  指定Panel中按钮的位置。可配置的值有'right', 'left' 和 'center'(对于所有的buttons/fbar默认为'right',对于toolbar 则默认为'left')。

4、handler : function(){}

  按钮点击事件的触发。

5、关于标签fieldLabel与title

  title为要现实的标签文本。

  fieldLabel为域标签。它被附加了labelSeparator, 其位置和大小被labelAlign、 labelWidth和labelPad配置确认。

    labelSeparator: 插入到fieldLabel后面的字符。默认为":"

    labelAlign: 控制fieldLabel的位置和对齐方式。有效值为:

       "left" (默认) - 标签位于域的左边,其文本左对齐。其宽度由labelWidth配置确定。

       "top" - 标签位于域的顶端。

       "right" - 标签位于域的右边,其文本右对齐。其宽度由labelWidth配置确定。

    labelWidth: fieldLabel以像素为单位的宽度。只适用于 labelAlign设置了“left”或“right”。默认为"100"。

    labelPad: fieldLabel和输入域之间的像素空间的合计。默认为"5"。

【ExtJS】FormPanel 布局(一)的更多相关文章

  1. ExtJs FormPanel布局

    FormPanel有两种布局:form和column,form是纵向布局,column为横向布局.默认为后者.使用layout属性定义布局类型.对于一个复杂的布局表单,最重要的是正确分割,分割结果直接 ...

  2. Extjs关于FormPanel布局

    Extjs关于FormPanel布局 FormPanel有两种布局:form和column,form是纵向布局,column为横向布局.默认为后者.使用layout属性定义布局类型.对于一个复杂的布局 ...

  3. ExtJs常用布局--layout详解(含实例)

    序言: 笔者用的ExtJs版本:ext-3.2.0 ExtJs常见的布局方式有:border.form.absolute.column.accordion.table.fit.card.anchor ...

  4. 【ExtJS】FormPanel 布局(二)

    周末2天好好学习了下布局,现在都给实现了吧. 5.border布局: Border布局将容器分为五个区域:north.south.east.west和center.除了center区域外,其他区域都需 ...

  5. Extjs Column布局常见问题及解决方法

    原文地址:http://blog.csdn.net/weoln/article/details/4339533 第一次用Extjs的column布局时遇见了很多问题,记录下来,供大家参考.column ...

  6. Extjs.FormPanel

    刚刚学习ExtJS ,备注一哈代码 防止忘记... <html xmlns="http://www.w3.org/1999/xhtml"> <head runat ...

  7. Extjs Vbox布局方式,以及align种类,flex,pack属性含义简介

    VBox布局方式,熟悉下一下几个主要属性: 一.align:字符类型,指示组件在容器内的对齐方式.这个是基于容器的左上角来排列的.pack不同,pack是根据容器的最上边来显示的. 1.left(默认 ...

  8. 【ExtJS】 布局Layout

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

  9. formpanel布局的学习

    FormPanel有两种布局:form和column,form是纵向布局,column为横向布局.默认为后者.使用layout属性定义布局类型.对于一个复杂的布局表单,最重要的是正确分割,分割结果直接 ...

随机推荐

  1. [leetcode] 2. Pascal's Triangle II

    我是按难度往下刷的,第二道是帕斯卡三角形二.简单易懂,题目如下: Given an index k, return the kth row of the Pascal's triangle. For ...

  2. NET分页实现及代码

    最近在写一个关于NET的框架,写到后面果不其然的就遇到了分页,自己看了很多关于分页的并自己结合写了一个,晒出来和大家分享一下,第一次写博客望大家多多提意见啦... cs文件分页代码: Paging p ...

  3. 使用 JSON JavaScriptSerializer 进行序列化或反序列化时出错

    如题 报错提示: 使用 JSON JavaScriptSerializer 进行序列化或反序列化时出错.字符串的长度超过了为 maxJsonLength 属性设置的值.","Sta ...

  4. Entity Framework异步查询和保存

    EF6开始提供了通过async和await关键字实现异步查询和保存的支持(.net 4.5及更高版本).虽然不是所有的操作都能从异步中获益,但是耗时的操作.网络或IO密集型任务中,使用异步可以提升客户 ...

  5. django DatabaseFunctions

    from django.db.functions import ... Cast() 转换类型 value = Value.objects.annotate(field_as_float=Cast(' ...

  6. Python【读取文件,第一行与最后一行】

    文件小的读取方法 with open("a1.txt","r",encoding="gbk") as f: r = f.readlines( ...

  7. 279. 完全平方数 leetcode JAVA

    题目: 给定正整数 n,找到若干个完全平方数(比如 1, 4, 9, 16, ...)使得它们的和等于 n.你需要让组成和的完全平方数的个数最少. 示例 1: 输入: n = 12 输出: 3 解释: ...

  8. mysqli扩展库---------预处理技术

    1, PHP程序与mysql之间处理sql语句流程如下,减少执行时间方式有三种: ① 减少php发送sql次数: ② 减少php与mysql之间网络传输时间: ③ 减少mysql的编译时间: 2, 预 ...

  9. [Objective-C语言教程]变量(6)

    变量是程序可以操作的存储区域的名称. Objective-C中的每个变量都有一个特定的类型,它决定了变量内存的大小和布局; 可存储在内存中的值的范围; 以及可以应用于变量的操作集. 变量的名称可以由字 ...

  10. win10环境下搭建虚拟环境和 virtualenvwrapper-win 使用

    1. 安装 virtualenv pip install virtualenv 2. virtualenv基本操作 cd path/dir # 跳转到dir目录 virtualenv env # 在d ...