PDA

View Full Version : Listener on radiobutton doesn't work properly.



marxan
30 Nov 2010, 6:59 AM
Hello,

I'm trying to use listener on 2 radiobuttons: when I click on one of them, it disabled a panel and when clicking on the other one, it should enable this panel.

In the following code, the listener to disable my panel works fine but when I click on the other button, nothing happens.

Any help would be appreciated.
Thanks,
Marxan


var typeOfReport = [{
xtype: 'radiogroup',
columns: [200, 0.7],
items: [{ boxLabel: '<font size="+1"> <B> Historic Report</B></font>',
name: 'GroupRadio',
inputValue: 'H',
checked: true,
listeners: {
check: function() {
var datePanel = Ext.getCmp('searchDate');
datePanel.setDisabled(false);
}
}
},
{ boxLabel: '<font size="+1"> <B>Dynamic Report </B></font>',
name: 'GroupRadio',
inputValue: 'D',
listeners: {
check: function() {
var datePanel = Ext.getCmp('searchDate');
datePanel.setDisabled(true);
}
}
}
]
}
]

Condor
30 Nov 2010, 7:22 AM
The 'check' event not only fires when the radio is selected, but also when it is deselected.

In your 'check' handler you need to check if the 2nd parameter is 'true'.

marxan
30 Nov 2010, 7:32 AM
Thanks for your answer Condor,

Not sure I'm clearly understand, I have to check if my other radiobutton is deselected?

So I have to put an ID to each button an retrieve their state to know if they are checked or not?

marxan
30 Nov 2010, 7:41 AM
Thanks again Condor.


var typeOfReport = [{
xtype: 'radiogroup',
columns: [200, 0.7],
items: [{ boxLabel: '<font size="+1"> <B> Historic Report</B></font>',
name: 'GroupRadio',
inputValue: 'H',
id: 'Hradio',
checked: true,
listeners: {
check: function() {
if (Ext.getCmp('DRadio').getValue() == false){
var datePanel = Ext.getCmp('searchDate');
datePanel.setDisabled(false);
}
}
}
},
{ boxLabel: '<font size="+1"> <B>Dynamic Report </B></font>',
name: 'GroupRadio',
// checked: true,
inputValue: 'D',
id: 'DRadio',
listeners: {
check: function() {
if (Ext.getCmp('DRadio').getValue() == true) {
var datePanel = Ext.getCmp('searchDate');
datePanel.setDisabled(true);
}
}
}
}
]
}
]

Condor
30 Nov 2010, 8:04 AM
check: function(cb, checked) {
if (checked) {
...
}
}