Extjs4 新的布局方式
来源:互联网 发布:淘宝古装衣服图片 编辑:程序博客网 时间:2024/04/29 11:24
本问介绍一个常见的??例子“联系我们”在弹出窗口的形式。表单使用vbox和hbox布局,以实现一个统一的灵活的布局。
JS代码:
- Ext.require([
- 'Ext.form.*'
- ]);
- Ext.onReady(function() {
- var win;
- function showContactForm() {
- if (!win) {
- var form = Ext.widget('form', {
- layout: {
- type: 'vbox',
- align: 'stretch'
- },
- bodyBorder: 0,
- fieldDefaults: {
- labelAlign: 'top',
- labelWidth: 100,
- labelStyle: 'font-weight:bold'
- },
- defaults: {
- margins: '0 0 10 0'
- },
- items: [{
- xtype: 'fieldcontainer',
- fieldLabel: 'Your Name',
- labelStyle: 'font-weight:bold;padding:0',
- layout: 'hbox',
- defaultType: 'textfield',
- fieldDefaults: {
- labelAlign: 'top'
- },
- items: [{
- flex: 1,
- name: 'firstName',
- fieldLabel: 'First',
- allowBlank: false
- }, {
- width: 30,
- name: 'middleInitial',
- fieldLabel: 'MI',
- margins: '0 0 0 5'
- }, {
- flex: 2,
- name: 'lastName',
- fieldLabel: 'Last',
- allowBlank: false,
- margins: '0 0 0 5'
- }]
- }, {
- xtype: 'textfield',
- fieldLabel: 'Your Email Address',
- vtype: 'email',
- allowBlank: false
- }, {
- xtype: 'textfield',
- fieldLabel: 'Subject',
- allowBlank: false
- }, {
- xtype: 'textareafield',
- fieldLabel: 'Message',
- labelAlign: 'top',
- flex: 1,
- margins: '0',
- allowBlank: false
- }],
- buttons: [{
- text: 'Cancel',
- handler: function() {
- this.up('form').getForm().reset();
- this.up('window').hide();
- }
- }, {
- text: 'Send',
- handler: function() {
- if (this.up('form').getForm().isValid()) {
- // In a real application, this would submit the form to the configured url
- // this.up('form').getForm().submit();
- this.up('form').getForm().reset();
- this.up('window').hide();
- Ext.MessageBox.alert('Thank you!', 'Your inquiry has been sent. We will respond as soon as possible.');
- }
- }
- }]
- });
- win = Ext.widget('window', {
- title: 'Contact Us',
- closeAction: 'hide',
- bodyPadding: 10,
- width: 400,
- height: 400,
- minHeight: 400,
- layout: 'fit',
- resizable: true,
- modal: true,
- items: [form]
- });
- }
- win.show();
- }
- var mainPanel = Ext.widget('panel', {
- renderTo: Ext.getBody(),
- title: 'Welcome!',
- width: 500,
- bodyPadding: 20,
- items: [{
- xtype: 'component',
- html: 'Thank you for visiting our site! We welcome your feedback; please click the button below to ' +
- 'send us a message. We will respond to your inquiry as quickly as possible.',
- style: 'margin-bottom: 20px;'
- }, {
- xtype: 'container',
- style: 'text-align:center',
- items: [{
- xtype: 'button',
- cls: 'contactBtn',
- scale: 'large',
- text: 'Contact Us',
- handler: showContactForm
- }]
- }]
- });
- });
代码实现在一个window窗口内使用新的布局方式(vbox和hbox)显示一个form表单,相对于Extjs 4.0之前的方式,将更加灵活。
- Extjs4 新的布局方式
- 一种新的布局方式
- extjs4.0的布局Layout
- Extjs4.0的新特性
- extjs4布局
- CSS3中新的布局方式flex box
- ExtJS4 Layout 布局
- Extjs4布局layout
- ExtJs4.1布局详解
- Extjs4布局layout
- Extjs4----border布局
- Extjs4---accordion布局
- Extjs4---card布局
- Extjs4----anchor布局
- Extjs4---absolute布局
- Extjs4---column布局
- Extjs4表单布局经验
- Extjs4 布局 layout 详解
- 努力学习 努力奋斗 踏步而立
- AS3 Signals之入门篇
- JMS学习笔记7
- Druid--高性能数据库组件
- Oracle 10g Auto Trace安装及SP2-0618和_SP2-0611错误处理
- Extjs4 新的布局方式
- Linux I2C应用程序
- jquery select radio 操作小结
- Mysql的DATE_FORMAT()进行日期格式转换
- whether you believe it or not, i believe!!
- jquery select onchange
- R12组织屏蔽
- linux系统时间修改
- 矩阵特征值和特征向量