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、最初のオプションを押しても2番目のオプションを押しても関係ありません。2番目のオプションがチェックされている場合にのみアラートを表示するべきではありませんか?

4

2 に答える 2

3

ラジオがチェックまたはチェック解除されるたびにイベントが発生します。

チェック:(Ext.form.Checkboxthis、ブールチェック済み)チェックボックスがオンまたはオフの場合に発生します。リスナーは次の引数で呼び出されます。this:Ext.form.Checkboxこのチェックボックスがオンになっている:ブール値新しいチェックされた値

  listeners: {
                          check : function(cb, value) {
                                if (value) alert('check');
                                   else alert('uncheck');
                           }
                     }
于 2011-09-08T12:44:17.800 に答える
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
}]
于 2014-11-12T05:10:24.270 に答える