Here’s how I’ve handled dynamic radios and value lists via mxml using a repeater…

 

The dataprovider used for the repeater is my list for the group. This is set dynamically based on the field in question.

“value” is the current value of the field stored in the DB…on each repeat it compares that to the current value being outputted in the repeater in order to set the ‘currently selected’ option.

 

When an item is clicked, I capture the current value of the option selected via event.target.data

 

HTH,

Stace

 

<mx:Form id="fieldForm" width="100%" height="100%" styleName="fieldForm">

                       

            <mx:FormItem width="100%">

                        <mx:Repeater id="fieldRepeater"

                                    dataProvider="{dp}">

                                    <mx:RadioButton groupName="radioGroup"

                                                label="{fieldRepeater.currentItem.description}"

                                                data="">

                                                click="radioFieldHelper.onChange( event )"

                                                selected="{fieldRepeater.currentItem.code == value}" />

                        </mx:Repeater>

            </mx:FormItem>

                       

</mx:Form>

 

 

 


From: [email protected] [mailto:[email protected]] On Behalf Of jwaknitz
Sent: Friday, July 15, 2005 6:27 PM
To: [email protected]
Subject: [flexcoders] Dynamic RadioButtonGroup

 

I am trying to dynamically create radio buttons within a
radiobuttongroup (which is dynamically being created).  This appears
to work. 
But, when I try to get the data out of the dynamically created
RadioButtonGroup, I get undefined.  I can tell that the group exists
because I can see that path that the object is in.  If I try to do
any properties on the Group I get undefined.  Even the ID property
returns undefined. 

Does anyone have any experience with creating a dynamic
RadioButtonGroup and how I would go about getting the data out? 

Here is a simplified version of my code with only one
RadioButtonGroup that isn't being named dynamically, should be doing
about the same thing though.

================================================

function appComp()
{     
      list = new Object();
     
      rbg = cont.createChild(RadioButtonGroup, undefined,
{id: "group1"});
      list[0] = rbg;
     
      for (var i=0; i<10; i++)
      {
            var rb = cont.createChild(RadioButton);
            rb.groupName=rbg.id;
            rb.label=rb.groupName;
      }
     
        //This shows correctly
      sOutput += list[0].id;
       
}

function btnPush()
{
        //This shows me the path of the RadioButtonGroup
      sOutput += list[0];

        sOutput += list[0].id; // = undefined
        sOutput += list[0].selection.id; // = undefined
}






--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




YAHOO! GROUPS LINKS




Reply via email to