Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Flex, how do I deselect all radio buttons in a group?

In Flex, sometimes when you need to clear a form you run into the problem that radio button groups seem to defy clearing: try as you might, setting selected=false on all buttons, setting selection=null on the group, doing both, doing them twice, etc., you always seem to end up with one pesky little radio button that's still selected. How do you solve this and restore the radio button group to its initial no-selection state?

like image 869
Daniel Brockman Avatar asked Jul 06 '09 15:07

Daniel Brockman


People also ask

How do I uncheck all radio buttons?

If you want to uncheck all the radio buttons and checkboxes you will need to add one single line (in bold): $('#clear-all').

Can we select and deselect radio button?

Radio button helps in ensuring only one option is selected. However, it doesn't allow user to deselect the option. We tried to set the value of Radio button as null when user is selecting the same option again.

Can we select multiple radio buttons?

Only one radio button in a group can be selected at the same time. Note: The radio group must have share the same name (the value of the name attribute) to be treated as a group.


2 Answers

You need to group all of the radio buttons into a RadioButtonGroup and then set the group selection to null:

<mx:RadioButtonGroup id="myGroup" />

<mx:RadioButton label="One" groupName="myGroup" />
<mx:RadioButton label="Two" groupName="myGroup" />
<mx:RadioButton label="Three" groupName="myGroup" />

<mx:Button label="Clear" click="myGroup.selection = null;" />
like image 73
darronschall Avatar answered Oct 01 '22 18:10

darronschall


You could try setting all of your radio buttons to a RadioButtonGroup then set RadioButtonGroup.selection to null

See http://livedocs.adobe.com/flex/3/langref/mx/controls/RadioButtonGroup.html#includeExamplesSummary for reference on how to implement the RadioButtonGroup control.

like image 28
bkildow Avatar answered Oct 01 '22 18:10

bkildow