2011-09-08 56 views
1
{xtype : 'radiogroup', 
      items : [{ 
       boxLabel : 'jjj', 
       name : 'tyutrfytr', 
       inputValue : 1, 
       checked : true 
      }, { 
       boxLabel : 'kkk', 
       name : 'dfdsfdsddd', 
       inputValue : 2, 
       listeners: { 
         check : function(cb, rec, ind) { 
          alert('hhhh'); 
         } 
       } 
      }] 
} 

无论按下第一个选项还是第二个选项,上面的代码都给出alert。不应该只在第二个选项被选中时才会提醒。如何聆听是否使用ExtJS检查单选按钮?

回答

3

每当收音机被选中或取消选中的事件触发..

检查:(Ext.form.Checkbox此,布尔检查) 火灾时该复选框被选中或取消选中。 听众将有以下参数调用: 这样的:Ext.form.Checkbox 此复选框选中 :布尔 新的检查值

listeners: { 
          check : function(cb, value) { 
           if (value) alert('check'); 
            else alert('uncheck'); 
          } 
        } 
1

此代码的工作以及在4.2版本:

xtype: 'radiogroup', 
id: 'RadioGroupId', 
fieldLabel: 'The Radio Group', 
items: [{ 
    xtype: 'radiofield', 
    boxLabel: 'The first radio', 
    id: 'FirstRadioId', 
    name: 'radios', 
    inputValue: 1, 
    listeners: { 
     change: function (cb, newValue, oldValue) { 
      if (newValue) { 
       // First radio button has been selected 
      } else { 
       // Second radio button has been selected 
      } 
     } 
    } 
}, { 
    xtype: 'radiofield', 
    boxLabel: 'The second radio', 
    id: 'SecondRadioId', 
    name: 'radios', 
    inputValue: 2, 
    checked: true 
}] 
相关问题