I have a radiogroup as follows :
{
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;
}
}
}
}
]
}
When I click the radio's, I can see selected radio input value in the console. But, change
event that available in the listener doesn't fire, nothing happen. Am I doing wrong something?
Fix:
The value coming from radio is a string so that we should cast to integer or use string in the switch statement, thanks @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;
}
}
}