Ric*_*ler 2 extjs listener radio-button
我想在工具栏中添加3个radiobutton,如下所示:
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'
}
]
}
]
}
]
Run Code Online (Sandbox Code Playgroud)
我想为这些按钮使用一个监听器.当有人点击离线我想加载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
}
}
}
}
Run Code Online (Sandbox Code Playgroud)