【发布时间】:2020-11-22 14:04:03
【问题描述】:
我正在创建一个包含两个收音机的收音机组; 我在 radiogroup 上设置了一个更改侦听器,一切似乎都工作正常,只是在单击时未检查单选按钮,请参见下面的完整代码:
Ext.define('Mine.view.headerThemeButton', {
extend: 'Ext.panel.Panel',
alias: 'widget.headerThemeButton',
xtype: 'headerThemeButton',
width: 50,
height: 58,
padding: 'auto 0 auto 0',
bodyStyle: 'border-color: #FFFFFF !important;',
//id : 'headerThemeButton',
//height: 20,
items: [{
xtype: 'button',
height: '100%',
glyph: 'xf142@FontAwesome',
cls: 'headerButtonsCls',
listeners: {
click: function(e, target) {
var coords = e.getXY();
var x = parseInt(coords[0]);
var y = parseInt(coords[1]);
var finalY = y + 50;
Ext.create('Ext.menu.Menu', {
items: [{
xtype: 'radiogroup',
columns: 1,
vertical: true,
items: [{
//xtype: 'radiofield',
boxLabel: 'Dark Mode',
name : 'Mode',
//id : 'dmRB',
inputValue : 'dm'
}, {
//xtype: 'radiofield',
boxLabel: 'Standard Mode',
name : 'Mode',
//id : 'smRB',
inputValue : 'sm'
}],
listeners : {
change : function(radio, newValue, oldValue){
if (radio.getValue().Mode == 'dm'){
radio.checked = true;
this.onChangeThemeDark();
}
else if (radio.getValue().Mode == 'sm'){
radio.checked = true;
this.onChangeThemeStandard();
}
}
}
}]
}).showAt(x, finalY);
}
}
}]
});
我不能在每个收音机上使用 id 道具,因为这会引发重复注册错误。 有什么解决办法吗?
谢谢!
编辑:整个按钮包含在由以下定义的界面中:
Ext.define('Mine.view.newDashboard', {
extend: 'Ext.container.Viewport',
alias: 'widget.newDashboard',
controller: 'newDashboard',
reference: 'dashboard',
//overflowY: 'scroll',
//autoScroll:true,
layout: {
type: 'border',
align: 'stretch '
//scrollable: true
},
/*viewConfig:
{
autoScroll: true
},*/
//height: 620,
style: {
'backgroundColor': '#909090 !important'
},
items: [{
region: 'north',
html: '',
border: false,
collapsible: false,
margin: '0 0 0 0',
resizable: false,
//bodyStyle:'border-bottom-width: 0 !important;',
layout: {
type: 'hbox'
// align: 'stretch'
},
items: [{
xtype: 'logolink',
padding: 'auto 0 auto 0'
},
{
xtype: 'tbfill'
},
{
xtype: 'headerThemeButton',
width: '100px'
},...
【问题讨论】: