次のようなラジオグループがあります。
{
xtype: 'fieldset',
title: 'MÜŞTERİ TİPİ SEÇİMİ',
layout: 'anchor',
height: 80,
defaults: {
anchor: '100%'
},
items: [
{
xtype: 'radiogroup',
anchor: 'none',
layout: {
autoFlex: false
},
defaults: {
margin: '0 5 0 0'
},
cls: 'customer-radio-group',
items: [
{boxLabel: 'TÜM MÜŞTERİ', name: 'cstgrp', inputValue: '1'},
{boxLabel: 'HORECA', name: 'cstgrp', inputValue: '2'},
{boxLabel: 'TRADER', name: 'cstgrp', inputValue: '3'},
{boxLabel: 'SCO', name: 'cstgrp', inputValue: '4'},
{boxLabel: 'BRANŞ', name: 'cstgrp', inputValue: '5'},
{boxLabel: 'HEDEF GRUP', name: 'cstgrp', inputValue: '6'},
{boxLabel: 'CTG', name: 'cstgrp', inputValue: '7'}
],
listeners: {
change: function (field, newValue, oldValue) {
//var value = Ext.ComponentQuery.query('radiofield[name=cstgrp]');
//console.log(newValue['cstgrp']);
switch (newValue['cstgrp']) {
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
case 6:
break;
case 7:
console.log('CTG Secildi...');
break;
}
}
}
}
]
}
ラジオをクリックすると、選択したラジオ入力値がコンソールに表示されます。しかし、change
リスナーで利用可能なイベントは発火せず、何も起こりません。私は何か間違ったことをしていますか?
修正:
radio からの値は文字列であるため、整数にキャストするか、switch ステートメントで文字列を使用する必要があります。@rixo に感謝します。
listeners: {
change: function (field, newValue, oldValue) {
//var value = Ext.ComponentQuery.query('radiofield[name=cstgrp]');
//console.log(newValue['cstgrp']);
switch (parseInt(newValue['cstgrp'])) {
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
case 6:
break;
case 7:
console.log('CTG Secildi...');
break;
}
}
}