zoukankan      html  css  js  c++  java
  • Extjs的DataField、Checkbox、RadioGroup控件

    1、DataField

    定义

    this._dateFieldApplyDate = new Ext.form.DateField({
    fieldLabel: '申请时间',
    value: expertApply.get('id') ? expertApply.get('expertApplyTime') : new Date(),
    disabled: true,
    allowBlank: false,
     200
    });

    DataField的用法和TextField的用法基本上是一样的,只不过用上了DataField会显示的方式不同而已,在验证上和普通的Textfield是一样的,赋值的时候会有所不同,需要转换一下格式,比如 this._dateFieldApplyDate.getValue().format('Y/m/d');是取出当前框内的值并转换为y/m/d格式,便于数据库保存,需要说明的是,如果当前框内为空,会报错,所以最好的办法是把默认时间为当天填进去。

    2、Checkbox

    定义

     this._checkBox1 = new Ext.form.Checkbox({
    fieldLabel: '是否已婚',
    checked: expert.get('isMarried'),
    disabled: isShow
    });
    
    //在checkBox内我用的是check事件,定义的方式和Textfield的validator事件还有comboBox的select事件是一样的,根据不同的选择实现不同的结果。
    
    this._checkboxOnChange = function (checkbox) {
    checkbox.panel._projectBasicPanel1.isVisible() ? checkbox.panel._projectBasicPanel1.setVisible(false) : 
    checkbox.panel._projectBasicPanel1.setVisible(true); } this._checkBox1.panel = this; this._checkBox1.on('check', this._checkboxOnChange);

    3、RadioGroup

    在使用的时候,根据不同的情况自己构造了需要的,首先按照自己的需求进行定义,抽象出自己需要的控件便于在大型的程序中多次使用

    定义

     this._radioAudit = new Vpms.component.RadioGroup({
    fieldLabel: '审核意见',
    allowBlank: false,
     250,
    items: Vpms.component.RadioGroup.AuditStoreFunction(auditState)//包含的选项数目
    });
    
    真正的RadioGroup的定义,当然也是继承自Ext.form.RadioGroup
    
    Ipms.component.RadioGroup = Ext.extend(Ext.form.RadioGroup, {
    getName: function () {
    return this.items.first().getName();
    },
    getValue: function () {
    var v;
    this.items.each(function (item) {
    v = item.getRawValue();
    return !item.getValue();
    });
    return v;
    },
    setValue: function (v) {
    this.items.each(function (item) {
    item.setValue(item.getRawValue() == v);
    });
    },
    getRadio: function (i) {
    return this.items.get(i);
    }
    
    });
    
    Ipms.component.RadioGroup.AuditStoreFunction = function (state) {
        var items = [{
        readOnly: false,
        boxLabel: '通过',
         100,
        name: 'Audit',
        inputValue: 'Agree',
        checked: state == ‘1’ ? true : false
    }, {
        readOnly: false,
        boxLabel: '驳回',
        100,
        name: 'Audit',
        inputValue: 'Reject',
        checked: state == ‘2’ ? true : false
    }];
    return items;
    }

    这里的RadioGroup在getValue()的时候get到的就是其中的inputValue。

  • 相关阅读:
    在Struts 2中使用JSON Ajax
    Android应用开发之(JSON解析库的选择)
    Unable to open log device '/dev/log/main': No such file or directory
    程序员的艺术:排序算法舞蹈
    博客园,我来迟了
    Android Service AIDL 远程调用服务之简单音乐播放实例
    Android Eclipse logcat 只显示一行的问题
    ERROR/WindowManager(***): Activity *** has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@*** that
    android布局属性详解
    Google为Android开发者提供定制的Eclipse IDE
  • 原文地址:https://www.cnblogs.com/jzwh/p/3086163.html
Copyright © 2011-2022 走看看