【发布时间】:2017-07-17 15:40:33
【问题描述】:
我有一个单选组字段,其中包含两个单选按钮。默认情况下选中一个单选按钮。当我单击另一个时,更改事件会触发并呈现一条确认消息,说明是或否。如果单击“是”,则该值将更改。如果单击 NO,则值应保持不变。
例如默认选择第 2 项。如果我单击项目 1,然后单击否。应检查第 2 项,但不要检查第 1 项。
var RG = Ext.create({
xtype: 'radiogroup',
fieldLabel: 'Two Columns',
// Arrange radio buttons into two columns, distributed vertically
columns: 2,
vertical: true,
items: [
{ boxLabel: 'Item 1', name: 'rb', inputValue: '1' },
{ boxLabel: 'Item 2', name: 'rb', inputValue: '2', checked: true}
],
listeners:{
'change':function(cmp, newValue, oldValue){
Ext.Msg.show({
title:'Save Changes?',
message: 'Would you like to save your changes?',
buttons: Ext.Msg.YESNO,
icon: Ext.Msg.QUESTION,
fn: function(btn) {
if (btn === 'yes') {
alert('Yes pressed');
} else if (btn === 'no') {
alert('No pressed');
//New Code
}
}
});
}
}
});
Ext.create('Ext.form.Panel', {
title: 'RadioGroup Example',
width: 300,
height: 125,
bodyPadding: 10,
renderTo: Ext.getBody(),
items:[RG]
});
请让我知道如何进行适当的更改以实现此行为。
提前致谢!
【问题讨论】:
标签: extjs radio-button extjs5 radio-group