ExtJS 4-放射组侦听器事件火灾
我有一个放射组,如下所示:ExtJS 4-放射组侦听器事件火灾,extjs,extjs4,extjs4.2,Extjs,Extjs4,Extjs4.2,我有一个放射组,如下所示: { xtype: 'fieldset', title: 'MÜŞTERİ TİPİ SEÇİMİ', layout: 'anchor', height: 80, defaults: { anchor: '100%'
{
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;
}
}
}
javascript中使用的switch语句。因此,在案例中必须使用字符串而不是整数:
case '7':
console.log('...');
break;
你的问题不清楚,我真的不明白你在问什么。如果
change
事件没有触发,您在控制台中看到了什么?亲爱的Evan,我有一个错误,即switch
语句中的值应该是字符串格式,因此更改事件没有触发就是因为这个。