我有一个无线电组如下:
{
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;
}
}
}