Flex help: repeaters are not duplicated in Compliance

I am having a problem relaying child repeaters inside the accordion control box, I hope you can help ...

I have an accordion in a ViewStack (from which the ViewStack is also in another top level ViewStack). I have a repeater in every accordion child. The component looks like this:

<mx:Accordion creationComplete="accordianInit()">
    <mx:Box label="Groups" width="100%">
        <mx:Repeater id="rpGroups" width="100%">
            <mx:CheckBox id="chkGroups" 
                label="{rpGroups.currentItem.name}" />
    <mx:Box label="Contacts">
        <mx:Repeater id="rpContacts">
            <mx:CheckBox id="chkContacts" 
                label=quot;{rpContacts.currentItem.full_name}" />



The problem is, if I bind 2 repeaters to the init function , then both repeaters will not show any data. If I bind the repeaters in the accordianInit function then only the first repeater (rpGroups) gets the data binding ...

Where should I bind the repeater data so that both repeaters repeat correctly?

Hope this makes sense, if I can't elaborate further, any help would be appreciated.


source to share

1 answer

Bind the repeater dataProvider to a source in the MXML itself:

<mx:Repeater dataProvider="{the_data}" ... />


The reason you see your behavior is because the Accordion (and ViewStack) doesn't create all of its children at once. It only creates a child view that is visible (so the first drawer and the first ViewStack).

Because of this behavior, when you try to assign data to repeaters in the first init () event handler, the repeaters do not have an instance container to re-enable children. When you assign data to repeaters in accordionInit (), then only the first box is created, so only the first repeater works.

If you don't want to bind to the data through the dataProvider attribute of the Repeater tag (as shown above), you can use the change handler in the Accordion to set the relay data when the user changes it (since when the user clicks on the panel, it is created by the Flex framework).

This all comes from the creationPolicy property: http://livedocs.adobe.com/flex/3/html/layoutperformance_05.html



All Articles