Ext.js5(表单)的容器(表单load测试数据)(表单填写的数据的保存)(vtype)(combineErrors)(插入())(文本框的布局)(36)
来源:互联网 发布:手机淘宝密码修改 编辑:程序博客网 时间:2024/05/29 11:12
view
/** * The FieldContainer\'s child items are arranged like in any other container, using the * layout configuration property. In this example, each FieldContainer is set to use an * HBox layout. *在文本容器里布局和其他容器里布局一样的,都是使用布局属性配置。在这个例子中,没有文本同期都是用HBOX布局。 * FieldContainers can be configured with the combineErrors option, which combines errors * from the sub fields and presents them at the container level. In this example the * Availability, Phone and Full Name items have this option enabled, and the Time worked * item does not. * 文本容器还可以配置一个联合错误的选项。具体怎么用的,看例子。本例子中Availability, Phone and Full Name 设置了这个选项,Time没有。 */Ext.define('KitchenSink.view.form.FieldContainer', { extend: 'Ext.form.Panel', xtype: 'form-fieldcontainer', controller: 'form-fieldcontainer', title: 'Employee Information', width: 600, bodyPadding: 10, defaults: { anchor: '100%', labelWidth: 100 }, items: [{ xtype: 'textfield', name: 'email', fieldLabel: 'Email Address', vtype: 'email',//文本输入格式的验证 msgTarget: 'side', allowBlank: false }, { xtype: 'fieldcontainer', fieldLabel: 'Availability', //如果设置为 true, 则 field 容器自动将其包含的所有属性域的校验错误组合为单个错误信息, 并显示到 配置的 msgTarget 上. 默认值 false. combineErrors: true, msgTarget : 'side', layout: 'hbox', defaults: { flex: 1, hideLabel: true }, items: [{ xtype: 'datefield', name: 'startDate', fieldLabel: 'Start', margin: '0 5 0 0', allowBlank: false }, { xtype : 'datefield', name : 'endDate', fieldLabel: 'End', allowBlank: false }] }, { xtype: 'fieldset',//html中的legend title: 'Details', collapsible: true,//这个可折叠,真的太人性化了 defaults: { labelWidth: 90, anchor: '100%', layout: 'hbox' }, items: [{ xtype: 'fieldcontainer', fieldLabel: 'Phone', combineErrors: true, msgTarget: 'under', defaults: { hideLabel: true, //True时潜在的输入表单项中设置最大长度属性。在默认为false enforceMaxLength: true, maskRe: /[0-9.]/ }, items: [ //太神奇了,插入()样式竟然是这样写的 {xtype: 'displayfield', value: '(', margin: '0 2 0 0'}, {xtype: 'textfield', fieldLabel: 'Phone 1', name: 'phone-1', width: 45, allowBlank: false, maxLength: 3}, {xtype: 'displayfield', value: ')', margin: '0 5 0 2'}, {xtype: 'textfield', fieldLabel: 'Phone 2', name: 'phone-2', width: 45, allowBlank: false, margin: '0 5 0 0', maxLength: 3}, {xtype: 'displayfield', value: '-'}, {xtype: 'textfield', fieldLabel: 'Phone 3', name: 'phone-3', width: 60, allowBlank: false, margin: '0 0 0 5', maxLength: 4} ] }, { xtype: 'fieldcontainer', fieldLabel: 'Time worked', combineErrors: false, defaults: { hideLabel: true, margin: '0 5 0 0' }, items: [{ name : 'hours', xtype: 'numberfield', minValue: 0, width: 95, allowBlank: false }, { xtype: 'displayfield', value: 'hours' }, { name : 'minutes', xtype: 'numberfield', minValue: 0, width: 95, allowBlank: false }, { xtype: 'displayfield', value: 'mins' }] }, { xtype : 'fieldcontainer', combineErrors: true, msgTarget: 'side', fieldLabel: 'Full Name', defaults: { hideLabel: true, margin: '0 5 0 0' }, items: [{ //the width of this field in the HBox layout is set directly //the other 2 items are given flex: 1, so will share the rest of the space width: 75, xtype: 'combo', queryMode: 'local', value: 'mrs', //triggerAction触发器被点击时执行的操作。 //'all' 指定allQuery配置项执行查询 //'query' 使用原始值执行查询 triggerAction: 'all', //forceSelection true时,所选择的值限制在一个列表中的值,false时,允许用户设置任意的文本字段 forceSelection: true, //设置为false阻止直接在表单项的文本框中输入字符;这时表单项只能通过从选择器(picker)中来选择值。 在这种模式下,也可以通过直接点击输入框本身来使选择器(picker)弹出。 editable: false, fieldLabel: 'Title', name: 'title', displayField: 'name', valueField: 'value', store: { fields: ['name', 'value'], data: [ {name : 'Mr', value: 'mr'}, {name : 'Mrs', value: 'mrs'}, {name : 'Miss', value: 'miss'} ] } }, { xtype: 'textfield', flex : 1, name : 'firstName', fieldLabel: 'First', allowBlank: false }, { xtype: 'textfield', flex : 1, name : 'lastName', fieldLabel: 'Last', allowBlank: false }] }] }], buttons: [{ text : 'Load test data', handler: 'onLoadClick' }, { text : 'Save', handler: 'onSaveClick' }, { text : 'Reset', handler: 'onResetClick' }]});
model
Ext.define('KitchenSink.model.PartTimeEmployee', { extend: 'KitchenSink.model.Base', fields: [ {name: 'email', type: 'string'}, {name: 'title', type: 'string'}, {name: 'firstName', type: 'string'}, {name: 'lastName', type: 'string'}, {name: 'phone-1', type: 'string'}, {name: 'phone-2', type: 'string'}, {name: 'phone-3', type: 'string'}, {name: 'hours', type: 'number'}, {name: 'minutes', type: 'number'}, {name: 'startDate', type: 'date'}, {name: 'endDate', type: 'date'} ]});
viewcontroller
Ext.define('KitchenSink.view.form.FieldContainerController', { extend: 'Ext.app.ViewController', alias: 'controller.form-fieldcontainer', requires: [ 'KitchenSink.model.PartTimeEmployee' ], onLoadClick: function() { this.getView().loadRecord(Ext.create('KitchenSink.model.PartTimeEmployee', { 'email' : 'abe@sencha.com', 'title' : 'mr', 'firstName': 'Abraham', 'lastName' : 'Elias', 'startDate': '01/10/2003', 'endDate' : '12/11/2009', 'phone-1' : '555', 'phone-2' : '123', 'phone-3' : '4567', 'hours' : 7, 'minutes' : 15 })); },//弹出了包含所填字段的信息框(应该confirm好过alert,私以为) onSaveClick: function() { var form = this.getView(), encode = Ext.String.htmlEncode, s = ''; if (form.isValid()) { Ext.iterate(form.getValues(), function(key, value) { value = encode(value); s += Ext.util.Format.format("{0} = {1}<br />", key, value); }, this); Ext.Msg.alert('Form Values', s); } }, onResetClick: function() { this.getView().reset(); }});
0 0
- Ext.js5(表单)的容器(表单load测试数据)(表单填写的数据的保存)(vtype)(combineErrors)(插入())(文本框的布局)(36)
- Ext.js5表单的文件上传(toast)(30)
- Ext.js5表单—有真实的load,submit行为的表单(reader在json.xml中record的区别)(49)
- Ext.js5表单—验证vtype扩展(时间段以及密码确认)(50)
- Ext.js5表单—(triggers触发器)(baseCSSPrefix)(specialkey)利用Ext.js提供的框架创建自己的表单(查询表单)(51)
- 表单填写 大气的全屏形式概念表单(精)
- Ext.js5表单—(在mousedown的时候就进行验证)(并且显示错误信息的时候样式会自动变化)hbox的布局(47)
- 表单验证(使用Vtype)
- Ext.js5含网格的表单(并且点击网格的时候,信息会传递到表单中,包括Radio的值)(32)
- Ext.js 古怪的问题(表单布局崩溃)
- Ext.js5表单—即时查询(结合Ext.Template和远程数据)(52)
- Ext.js5表单文本—数字(24)
- Ext.js5小鲱鱼域(表单域)(39)
- .net 火车头 ------表单(form)的自动填写和提交
- .net 火车头 ------表单(form)的自动填写和提交
- WebBrowser控件表单(form)的自动填写和提交
- Ext.js5(弹出搜索表单)(给一个面板添加数据)(34)
- 不用Cookie,如何保存表单所填写的数据
- js 基本数据类型、对象、数组的传递
- 细谈之AutoLayout全解
- W3School的SQL测试
- CentOS 7 设置开启默认启用命令行模式而非图形界面
- <LeetCode OJ> 19. Remove Nth Node From End of List
- Ext.js5(表单)的容器(表单load测试数据)(表单填写的数据的保存)(vtype)(combineErrors)(插入())(文本框的布局)(36)
- 接收系统广播
- MBR 之 硬盘基本知识(磁道、扇区、柱面、磁头数、簇、MBR、DBR)
- Testing Support Library在Android测试中的使用
- Spark + ansj 对大数据量中文进行分词
- Android Application之onLowMemory与omTrimMemory
- 安卓打包签名之-export aborted because fatal lint errors were found
- 产品策划一:移动App项目研发流程及版本规划
- Description Resource Path Location Type Java compiler level does not match the version of the instal