PDA

View Full Version : RadioGroup get GroupValue



rchen5990@gmail.com
14 Nov 2012, 12:09 PM
Hi All,

I am migrating my Ext JS 3 app to 4 and I am running into a little trouble with radiogroup.

var testSearchCriteria = Ext.create('Ext.form.Panel',{
items: [{
xtype: 'radiogroup',
fieldLabel: 'Test Search Criteria',
columns : 1,
id: 'testSearchCriteria',
name: 'testSearchCriteria',
margins : '10 10 10 10',
items: [
{boxLabel: 'Test Suite Tango Id', name: 'id-1', inputValue : 'testSuiteTangoId', checked: true},
{boxLabel: 'Test Case Tango Id', name: 'id-1', inputValue : 'testCaseTangoId'},
{boxLabel: 'Test Area', name: 'id-1', inputValue : 'testArea'}
],
listeners:{
change : function(radiogroup,radio){
if(radio.getGroupValue == 'testSuiteTangoId'){
testTangoIdSearchKeyTextField.hide();
testAreaCombo.hide();
suiteTangoIdTextField.show();
} else if(radio.getGroupValue == 'testCaseTangoId') {
testTangoIdSearchKeyTextField.show();
suiteTangoIdTextField.hide();
testAreaCombo.hide();
} else if (radio.getGroupValue() == 'testArea'){
testTangoIdSearchKeyTextField.hide();
suiteTangoIdTextField.hide();
testAreaCombo.show();
}
}
}
}]
});


I get an error Uncaught TypeError: Object #<Object> has no method 'getValue'

Any help would be greatly appreciated.

Thanks,
Rich

greg.barry
14 Nov 2012, 1:18 PM
You should be able to do something along these lines:



var testSearchCriteria = Ext.create('Ext.form.Panel',{
items: [{
xtype: 'radiogroup',
fieldLabel: 'Test Search Criteria',
renderTo: Ext.getBody(),
columns : 1,
id: 'testSearchCriteria',
name: 'testSearchCriteria',
margins : '10 10 10 10',
items: [
{boxLabel: 'Test Suite Tango Id', name: 'id-1', inputValue : 'testSuiteTangoId', checked: true},
{boxLabel: 'Test Case Tango Id', name: 'id-1', inputValue : 'testCaseTangoId'},
{boxLabel: 'Test Area', name: 'id-1', inputValue : 'testArea'}
],
listeners:{
change : function(radiogroup,radio){
var groupValue = this.getValue()['id-1'];


if(groupValue === 'testSuiteTangoId'){
console.log("Radio 1 Checked");
} else if(groupValue === 'testCaseTangoId') {
console.log("Radio 2 Checked");
} else if (groupValue === 'testArea'){
console.log("Radio 3 Checked");
}
}
}
}]
});


Thanks!
Greg