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。

  • 相关阅读:
    Windows API Reference for C#, VB.NET and VB6
    工程建设项目综合信息管理系统
    GridView,Repeater分页控件:WebPager 开源了
    asp.net服务器控件开发学习之路(一)
    ajaxToolkit:TabContainer 背景色的设置
    TreeView 树结构的断层处理
    C# 集合类(二):Queue
    AutoCAD.net(三)用VS.NET2005开发ObjectARX程序 调试方法
    AutoCAD.net(一):更改AutoCAD窗口的标题和图标
    C# 集合类(四):Hashtable
  • 原文地址:https://www.cnblogs.com/jzwh/p/3086163.html
Copyright © 2011-2022 走看看