views:

347

answers:

1

I have a datagrid that I want to add a column of radio button using AS3 (instead of mxml). I was able to do this with a custom itemRenderer.

var dgc:DataGridColumn = new DataGridColumn();
dgc.itemRenderer = new ClassFactory(com.mypackage.RadioBtnColumnItemRenderer);

In my RadioBtnColumnItemRenderer.mxml, I have a box with a radioButton... like so:

<?xml version="1.0" encoding="utf-8"?>
<mx:Box 
xmlns:mx="http://www.adobe.com/2006/mxml"
horizontalAlign="center" verticalAlign="middle"
>
<mx:RadioButton id="btnRadio"
   groupName="btnRadioSelect"
/>
</mx:Box>

When I run the application, the radio button shows up in the column as it should. However, I cannot select just ONE of the radio buttons. I am able to select all of them, but I don't want this... I want the ability to select one, and then if I select another one, then the first one is unselected and the current one becomes selected (just like you would expect radio buttons to work).

What am I missing?

A: 

You'll need to define a RadioButtonGroup to have this select only one behavior. I think if you put this group in the item renderer, you won't be able to achieve the desired behavior though, so you may need to figure out a way to reference the group from the container holding the data grid.

http://livedocs.adobe.com/flex/3/langref/mx/controls/RadioButtonGroup.html

quoo
Exactly. It may be useful to look into uses for "outerDocument". http://www.coldfusionjedi.com/index.cfm/2007/4/10/Something-to-remember-when-working-with-inline-components-in-Flex
pcorey