我有一個有兩個單選按鈕的廣播組字段。默認情況下選中一個單選按鈕。當我點擊另一個時,更改事件觸發器並呈現一條確認消息,指出YES或NO。如果YES被點擊,則值會改變。如果單擊「否」,則值應保持不變。ExtJS廣播組 - 如何根據用戶確認設置數值?
例如第2項是默認選擇的。如果我點擊第1項,然後點擊NO。第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]
});
請讓我知道如何做出正確的改變來實現這種行爲。
在此先感謝!
cmp.reset();而不是cmp.setValue(oldValue);也有效 – josei