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?
If you want to uncheck all the radio buttons and checkboxes you will need to add one single line (in bold): $('#clear-all').
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.
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.
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;" />
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With