ExtJS表单组件RadioGroup属性用法(选中初始值、表单加载,选中取值)的要点

解决表单加载初始值,自动选中单选按钮组的问题,今早才查到资料,原来ext3.1已经修正了这个问题,但是需要的是给组和里面的单选按钮都要设置同样的name属性,我就是没有设定group的name,就悲剧了,这样设置即可: 

Js代码  收藏代码
  1. {    
  2.    xtype: 'radiogroup',  
  3.    fieldLabel: 'Auto Layout',  
  4.    name: 'rb-auto'
  5.    id:'atype', 
  6.    items: [          
  7. {boxLabel: 'Item 1', name: 'rb-auto', inputValue: 1},         
  8. {boxLabel: 'Item 2', name: 'rb-auto', inputValue: 2, checked: true},          
  9. {boxLabel: 'Item 3', name: 'rb-auto', inputValue: 3},          
  10. {boxLabel: 'Item 4', name: 'rb-auto', inputValue: 4},         
  11. {boxLabel: 'Item 5', name: 'rb-auto', inputValue: 5}      
  12. ]    
  13. }   
获取单选按钮的值的代码: var atype = Ext.getCmp('atype').getValue(); 
他的弹出值是[object Object],我查了JS基础,说是为空或者不是对象 
我的需求是:我要知道用户选了单选还是多选的按钮,我需要得到值。
取值方法:
  1.  buttons:[{  
  2.       text:'xx',  
  3.       handler:function(){  
  4.         var rg = Ext.getCmp('atype');  
  5.         var r = rg.getValue();  
  6.         //关键  
  7.         var value = r.inputValue;  
  8.         alert(value) ;       
  9.       }  
  10.     }]  
posted @ 2011-09-23 09:40  CloudCode  阅读(13361)  评论(0编辑  收藏  举报