Extjs 单选按钮侦听器
我想在工具栏中添加3个单选按钮,如下所示:Extjs 单选按钮侦听器,extjs,radio-button,listener,Extjs,Radio Button,Listener,我想在工具栏中添加3个单选按钮,如下所示: dockedItems: [ { xtype: 'toolbar', dock: 'top', items: [ { xtype: 'radiogroup', width: 500,
dockedItems: [
{
xtype: 'toolbar',
dock: 'top',
items: [
{
xtype: 'radiogroup',
width: 500,
fieldLabel: 'Show',
items: [
{
xtype: 'radiofield',
id: 'all',
name: 'show',
boxLabel: 'All vehicles',
checked: true
},
{
xtype: 'radiofield',
id: 'online',
name: 'show',
boxLabel: 'Online vehicles'
},
{
xtype: 'radiofield',
id: 'offline',
name: 'show',
boxLabel: 'Offline vehicles'
}
]
}
]
}
]
我想为这些按钮使用侦听器。当有人单击offline时,我想加载internals.load({url:internals/offline.json})
我就是不能让它工作。有什么建议/帮助吗
谢谢试试这个:
{
xtype: 'radiogroup',
width: 500,
fieldLabel: 'Show',
items: [
{
xtype: 'radiofield',
id: 'all',
name: 'show',
boxLabel: 'All vehicles',
checked: true,
inputValue: 'all'
},
{
xtype: 'radiofield',
id: 'online',
name: 'show',
boxLabel: 'Online vehicles',
inputValue: 'online'
},
{
xtype: 'radiofield',
id: 'offline',
name: 'show',
boxLabel: 'Offline vehicles',
inputValue: 'offline'
}
],
listeners: {
change: function(field, newValue, oldValue) {
var value = newValue.show;
if (Ext.isArray(value)) {
return;
}
if (value == 'offline') {
// do something
}
}
}
}
newValue.show将始终处于未定义状态。因为newvalue和old value是布尔值