日期:2014-05-16  浏览次数:20314 次

EXT JS CHECKGROUP 的使用
//注销原因
  cancellationReason1 : new Ext.form.CheckboxGroup({
   anchor : '95%',
   fieldLabel : '注销原因<font color=red>*</font>',
   columns: 1,
   xtype: 'checkboxgroup',
            itemCls: 'x-check-group-alt',
   name:'cancellationReason1',
   items:[
    {boxLabel:'不再从事报关业务',name: 'Reason-1',value:0},
    {boxLabel:'辞职',name: 'Reason-2',value:1},
    {boxLabel:'所在报关单位申请注销海关注册登记',name: 'Reason-3',value:2},
    {boxLabel:'报关单位解除与本人的劳动合同关系、聘用合同关系或者人事关系',name: 'Reason-4',value:3},
    {boxLabel:'其他',name: 'Reason-5',value:4}
    ]
  })



{

    layout : 'column',
    bodyStyle : '10 0 0 10',
    items : [
     {
      columnWidth : .9,
      labelWidth : 100,
      layout : 'form',
      items : [
      mySystem.configField(this.formField.cancellationReason1,10,"",this.formId)
      ]
     }]
      }



保存的时候 

var cancellationReason= "";
       var split = "";
       var cancellationReason1Item = this.formField.cancellationReason1.items;
       for(var i=0;i<cancellationReason1Item.length;i++){
           if(cancellationReason1Item.itemAt(i).checked){
               cancellationReason+=split+cancellationReason1Item.itemAt(i).value;
               split=",";
           }
       }
     var formJsonO = this.declarantOffForm.getForm().getValues();
     formJsonO.cancellationReason = cancellationReason;
     alert(Ext.encode(formJsonO));





读取的时候

setTimeout(function() {
    if (this.applyId!= -1) {
    mySystem.showDiv('dataLoading');
          this.declarantOffForm.getForm().paramOrder = ['className','keyClassName','key'];
    var o = { className: 'DeclarationManager', keyClassName:'Long', key : this.applyId };
    mySystem.showDiv('dataLoading');
    this.declarantOffForm.getForm().doAction("directload",{params: o,success:function(){
     var itemsValue =this.declarantOffForm.getForm().findField("cancellationReason").getValue();
     var arr =itemsValue.split(",");
     for(var i=0;i<arr.length;i++){
//         eval("this.formField.cancellationReason1.items.itemAt("+arr[i]+").checked = true;");
      for(var j=0;j<this.formField.cancellationReason1.items.length;j++){
       if(arr[i]==this.formField.cancellationReason1.items.itemAt(j).value){
         this.formField.cancellationReason1.items.itemAt(j).setValue(true);
       }
      }
        }
    }.createDelegate(this)}); 
   }

1 楼 GoodWell 2011-07-15  
学习了…………