View Full Version : How determine which radio button clicked in grid column?

25 Jan 2012, 5:32 AM
I would like to have a group of radio buttons in a grid column.
and then it is required to determine which button the user has

I have created the column renderer below:

Is there a way of setting the id of the radio button to be
different for each row?

n.b. aswell as the radio button column I have used
Ext.selection.CheckboxModel to create a checkbox column.

columns: [
html: 'Test',
dataIndex: 'test',
renderer: function(value) {
return '<input type="radio" name="group1" onclick="dispmsg()"/>';

Please advise if there's a better way of doing this?

Thank you,

25 Jan 2012, 5:36 AM
Your column renderer is passing much more than what you are using. It passes the row record as well to the renderer so you could do something like
record.get('recordID') in your dispmsg() function to get the key value. Same goes for setting the ID of the radio button. As far as getting the ones that are clicked you could try some variant of the Ext componentquery functions to see if you can get a filtered list that way. Not sure what the syntax would be for getting 'clicked' radio buttons and I don't use this functionality so I don't have a good way of testing it. Hope this helps.

25 Jan 2012, 6:23 AM
Thank you for your quick reply.

Please can you inform me how I can access the record and any other data
within the column renderer? What arguments are passed?
From the ext js 4 documentation, the renderer function only has 1 argument,
the value of the cell.
renderer: function(value){


25 Jan 2012, 6:26 AM
No, the documentation EXAMPLE only shows the value. If you look a little lower you see there is a whole bunch of other parameters and their definitions. http://docs.sencha.com/ext-js/4-0/#!/api/Ext.grid.column.Column-cfg-renderer (http://docs.sencha.com/ext-js/4-0/#%21/api/Ext.grid.column.Column-cfg-renderer)