PDA

View Full Version : RadioGroup click on already selected item



tzalberto
9 Jul 2013, 7:55 AM
Hi all,

I'm working with radio group, my code is as follows:



{
xtype: 'radiogroup',
id: 'myradios',
columns: 3,
horizontal: true,
items: [
{
inputValue: '3'
},
{
inputValue: '2'
},
{
inputValue: '1'
}
],
}


I need to know when the user clicks on the current selected radio.
I have tried using handler and also the change event but both are only fired when click is on a not selected radio (selected value changes). I need to caught event when click is on the same radio that is currently selected.

Any idea ?

friend
9 Jul 2013, 9:41 AM
You could register your own click event on the RadioGroup's DOM element:



var xx = Ext.create('Ext.window.Window', {
height: 200,
layout: 'anchor',
title: 'RadioGroup Test',
width: 350,
items: [{
xtype: 'radiogroup',
id: 'myradios',
columns: 3,
horizontal: true,
padding: 5,
items: [{
anchor: '33%',
boxLabel: 'Radio 3',
inputValue: '3',
name: 'someRadio'
},{
anchor: '33%',
boxLabel: 'Radio 2',
inputValue: '2',
name: 'someRadio'
},{
anchor: '33%',
boxLabel: 'Radio 1',
inputValue: '1',
name: 'someRadio'
}]
}]
}).show();

xx.down('radiogroup').el.on('click', function(evt, targetHtmlElement) {
console.log(targetHtmlElement);
});


The only downside to this is you're now dealing with DOM events and HTML nodes, but you can fairly easily cross-corrolate this back to the appropriate ExtJs component.

tzalberto
9 Jul 2013, 10:47 AM
Hi friend,

Since I have many other radiogroups I tried to get the radiogroup not by xtype but by id so I'm doing


Ext.getCmp('mygroupid').getEl().on('click', function(evt, element){
console.log('test');
});


Ext.getCmp('mygroupid') returns what I expect but when I call getEl() it returns undefined.