문제

{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');
                       }
                 }
            }]
}

The code above gives alert no matter whether I press first option or second option. Shouldn't it alert only when the second option is checked?

도움이 되었습니까?

해결책

the event fires whenever the radio gets checked or unchecked..

check : ( Ext.form.Checkbox this, Boolean checked ) Fires when the checkbox is checked or unchecked. Listeners will be called with the following arguments: this : Ext.form.Checkbox This checkbox checked : Boolean The new checked value

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

다른 팁

This code works well in version 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
}]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top