页面加载时 默认选中值为 '男'
选中'女'后保存。
进行编辑时再次进入这个页面,怎样把选中的值改成"女"?
new Ext.form.RadioGroup({   
    name:'selectsex',   
    id:'selectsex',   
    fieldLabel:'select',   
    hideLabel:true,   
    columns:2,   
    vertical:false,   
    items:[{   
        boxLabel:'男',inputValue:'1',name:'sex',checked:true  
        },{   
        boxLabel:'女',inputValue:'0',name:'sex'  
    }]   
})  

解决方案 »

  1.   

    在页面加载后(listeners: 'show':function(){...})中,先把后台返回的 sex 数据拿出来判断,然后 setValue(true)
      

  2.   


    能说的详细点么,不好意思哈,第一天看extjs,多谢
      

  3.   


    listeners: 'show':function(){...})具体加在什么地方?我怎么加到哪里都报错啊。。
      

  4.   

    最简单的方法,把下面的方法放在最前面,你可以把你放在一个单独的js文件中,然后先加载这个文件Ext.override(Ext.form.BasicForm,{     
        findField : function(id){             
            var field = this.items.get(id);             
            if(!field){     
                this.items.each(function(f){     
                    if(f.isXType('radiogroup')||f.isXType('checkboxgroup')){     
                            f.items.each(function(c){     
                               if(c.isFormField && (c.dataIndex == id || c.id == id || c.getName() == id)){     
                                   field = c;     
                                   return false;     
                               }     
                           });     
                       }     
                                            
                      if(f.isFormField && (f.dataIndex == id || f.id == id || f.getName() == id)){     
                           field = f;     
                           return false;     
                       }     
                  });     
               }     
               return field || null;     
       }      
    }); 下面是你form中的radiogroup的格式{xtype:'radiogroup',fieldLabel : "性别",name : 'sex',id: 'sex', anchor:'95%',columns: 2 ,items: 
      [{boxLabel: "男", name: 'sex',inputValue: 'M'},
               {boxLabel: "女", name: 'sex',inputValue: 'F'}
              ]}