flex 3: RadioButtonGroups - multiple groups of independent radio buttons
I tried to search, but I couldn't find what I was looking for... so sorry if this is a repost.
I need to create 10 separate radio button groups, each with three开发者_JAVA技巧 options (show, collapse, or hide). I've created the following:
<mx:HBox>
<mx:Text text="Directors Prep." width="125" />
<mx:RadioButtonGroup id="dprepRB" enabled="false" />
<mx:RadioButton id="dprepshow" label="Show" value="1" groupName="{dprepRB}" />
<mx:RadioButton id="dprepcollapse" label="Collapse" value="0" groupName="{dprepRB}" />
<mx:RadioButton id="dprephide" label="Hide" value="-1" groupName="{dprepRB}" selected="true" />
</mx:HBox>
<mx:HBox>
<mx:Text text="Check In/Out" width="125" />
<mx:RadioButtonGroup id="checkIORB" enabled="false" />
<mx:RadioButton id="checkioshow" label="Show" value="1" groupName="{checkIORB}" />
<mx:RadioButton id="checkiocollapse" label="Collapse" value="0" groupName="{checkIORB}" />
<mx:RadioButton id="checkiohide" label="Hide" value="-1" groupName="{checkIORB}" selected="true" />
</mx:HBox>
... and so on with the other 8 groups
On load, I would like the "Hide" button to be selected. However, when the application loads, only the hide button on the last group is selected. If I select any other button on any other group, the "Hide" button from the last group is deselected, and the button I clicked becomes the only selected radio button. It seems like, for some reason, flex is thinking all the radio buttons belong to the same group. What am I doing wrong?
Thanks, Brds
Try to use:
<mx:HBox>
<mx:Text text="Directors Prep." width="125" />
<mx:RadioButtonGroup id="dprepRB" enabled="false" />
<mx:RadioButton id="dprepshow" label="Show" value="1" group="{dprepRB}" />
<mx:RadioButton id="dprepcollapse" label="Collapse" value="0" group="{dprepRB}" />
<mx:RadioButton id="dprephide" label="Hide" value="-1" group="{dprepRB}" selected="true" />
</mx:HBox>
See details here.
Hi my solution was to define the RadioButtonGroup is the declarations tag block:
<fx:Declarations>
<mx:RadioButtonGroup id="dprepRB"/>
</fx:Declarations>
And then use the group later on in the HBox or whatever:
<mx:HBox>
<mx:Text text="Directors Prep." width="125" />
<mx:RadioButton id="dprepshow" label="Show" value="1" group="{dprepRB}" />
<mx:RadioButton id="dprepcollapse" label="Collapse" value="0" group="{dprepRB}" />
<mx:RadioButton id="dprephide" label="Hide" value="-1" group="{dprepRB}" selected="true" />
</mx:HBox>
You should use group="" not groupname="". Then each independent radio button group can be selected.
Cheers
精彩评论