Ext.form.FormPanel的扩展

扩展Ext.form.FormPanel,加入form域,形成自己的formPanel

 

 

Ext.namespace("Ext.ux.form");
Ext.apply(Ext.form.VTypes, {
   password: function(val, field)
   {
    if (field.password.password_id)
    {
     var pwd = Ext.get(field.password.password_id);
     return (val == pwd.getValue());
    }
    return true;
   },
   passwordText: "两次密码输入不一致!"
  });
Ext.ux.form.TestForm = Ext.extend(Ext.form.FormPanel, {
   frame: true,
   width: 240,
   title: "测试用的form",
   autoHeigth: true,
   layout: "form",
   labelWidth: 70,
   labelAlign: "left",
   defaultType: "textfield",
   initComponent: function()
   {
    this.items = [{
       xtype: "textfield",
       id: "name",
       name: "name",
       fieldLabel: "姓名",
       allowBlank: false
      }, {
       xtype: "textfield",
       id: "password",
       inputType: 'password',
       name: "password",
       fieldLabel: "密码",
       allowBlank: false
      }, {
       xtype: "textfield",
       inputType: 'password',
       id: "re_password",
       name: "re_password",
       password: {
        password_id: 'password'
       },
       fieldLabel: "确认密码",
       allowBlank: false,
       vtype: 'password'
      }, {
       xtype: "numberfield",
       id: "age",
       name: "age",
       fieldLabel: "年龄",
       allowBlank: false
      }, {
       xtype: "datefield",
       id: "birthday",
       name: "birthday",
       fieldLabel: "生日",
       allowBlank: false
      }, {
       xtype: "checkbox",
       id: "married",
       name: "married",
       fieldLabel: "已婚",
       allowBlank: false
      }, {
       xtype: "combo",
       id: "home",
       name: "home",
       fieldLabel: "国籍",
       allowBlank: false,
       store: [["1", "中国"], ["2", "美国"], ["3", "火星"]],
       fieldLabel: '类型',
       displayField: 'desc',
       valueField: 'id',
       hiddenName: 'married',
       typeAhead: true,
       emptyText: '请选择国籍...',
       mode: 'local',
       triggerAction: 'all',
       selectOnFocus: true,
       editable: false,
       anchor: '95%',
       width: 200
      }, {
       xtype: "textarea",
       id: "note",
       name: "note",
       fieldLabel: "备注",
       allowBlank: false
      }];

    this.buttons = [{
       text: "提交",
       handler: this.save,
       scope: this
      }, {
       text: "取消",
       handler: function()
       {
        this.form.reset();
       },
       scope: this
      }];
    Ext.ux.form.TestForm.superclass.initComponent.call(this);
   },
   save: function()
   {
    if (this.form.isValid())
    {
     this.form.submit({
        params: {
         action: 'submit'
        },
        waitMsg: '正在保存...'
       });
    }
    else
    {
     Ext.MessageBox.alert('错误', '请正确填写出错项');
    }
   }

  });
Ext.reg("testForm", Ext.ux.form.TestForm);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值