2 Replies Latest reply on May 26, 2011 8:29 PM by NoMan'sLand

    Radiobutton Group in Datagrid

    ryan0220
      I have a datagrid with a radiobutton group in a column. I would like to make radiobuttons within the group visible or not based on their value.

      <mx:DataGridColumn headerText="Best 3 Historic Matches Based on POS" dataField="historic_end_date" rendererIsEditor="true" editorDataField="text" editable="true" width="300">
      <mx:itemRenderer>
      <mx:Component>
      <mx:VBox left="5">
      <mx:Script>
      <![CDATA[
      import mx.core.Application;
      [Bindable]
      public var text:String;
      ]]>
      </mx:Script>
      <mx:RadioButtonGroup id="week" selectedValue="{data.historic_end_date}" change="text=week.selectedValue.toString()"/>
      <mx:RadioButton id="rbWeek1" groupName="week" value="{data.week1_start}" label="{data.week1_start} - {data.week1_end} ({data.week1_pos})"/>
      <mx:RadioButton id="rbWeek2" groupName="week" value="{data.week2_start}" label="{data.week2_start} - {data.week2_end} ({data.week2_pos})"/>
      <mx:RadioButton id="rbWeek3" groupName="week" value="{data.week3_start}" label="{data.week3_start} - {data.week3_end} ({data.week3_pos})"/>
      </mx:VBox>
      </mx:Component>
      </mx:itemRenderer>
      </mx:DataGridColumn>

      If {data.week1_start} = "No Data", I would like to set rbWeek1.visible="false"

      Any ideas?

      Thanks!
        • 1. Re: Radiobutton Group in Datagrid
          ANewFlexUser
          Possibly the easiest would be to bind the 'visible' property to an implicit Boolean on your Array Collection. Add a method like this to your ActionScript class:

          public function get week1Enabled():Boolean {
          if( data.week1_start == "No Data")
          return false

          return true
          }

          then for your RadioButton, simply add the following two properties:

          visible="{data.week1Enabled}"
          includeInLayout="{data.week1Enabled}"

          You need to add 'includeInLayout' because otherwise, you'll get a blank spot where your radio button normally is. You'll have to add a getter like this for each button, but otherwise, it should do what you want it to.

          Hope this helps!
          • 2. Re: Radiobutton Group in Datagrid
            NoMan'sLand Level 1

            <fx:Declarations>

                <s:RadioButtonGroup id="rbtnGroup"/>
            </fx:Declarations>

             

            <mx:DataGrid>
                <components:columns>
                    <mx:DataGridColumn headerText="A" dataField="a">
                        <mx:itemRenderer>
                            <fx:Component>
                                <mx:HBox horizontalAlign="center" width="100%">
                                    <s:RadioButton group="{outerDocument.rbtnGroup}" />
                                </mx:HBox>
                            </fx:Component>
                        </mx:itemRenderer>
                    </mx:DataGridColumn>
                </components:columns>
            </mx:DataGrid>

             

             

             

             

             

             

            http://www.nomanland.net