Hi Tracy,

I simplified my original application to be able to concentrate on the
problem itself.
Since a VBox doesn't have a dataProvider that name is free for use. Also
i'm not that much interested in code beautifing here ;d.
The setter function is also not really needed because you can debug with
ChangeWatchers and it also doesn't work with a fully typed model (as in
my original App).

The problem is the following:

    * The ArrayCollection fires a collectionChanged Event
    * The Repeater whats to update the view recycling the existing
elements
    * The Repeater first goes through its children and updates their
bindings, which again updates the bindings of their children

    * The repeater of the RepeaterComponent doesn't do anything, but the
out repeater manipulates its childen

    * This is the point where everything goes wrong. Somehow all children
of RepeaterComponent are updated the way to use the repeaterIndex of the
outer Repeater, and that's the reason why I get 11,11,11 instead of
11,12,13
    * The Repeater adds the new element


--- In [email protected], "Tracy Spratt" <[EMAIL PROTECTED]> wrote:
>
> First, don't use the names of existing properties, methods or classes
> for your component, or variable names.  Specifically "dataProvider"
and
> "data".
>
>
>
> Next, use a setter function instead of a public property, so you can
> debug the values being passed in. Type the setter function as
> specifically as you can, avoid Object.
>
>
>
> ________________________________
>
> From: [email protected] [mailto:[EMAIL PROTECTED]
On
> Behalf Of nkopcsek
> Sent: Tuesday, January 08, 2008 9:51 AM
> To: [email protected]
> Subject: [flexcoders] Nested Repeaters: Weird Behaviour
>
>
>
> Hi,
>
> I got some really strange behaviour with nested repeaters.
> In this case a repeater is part of a component which is repeated
itself
> (let's call this component RepeatedComponent, see below for code).
> Whenever I add a new item to the dataProvider of the outer repeater it
> doesn't add only the new RepeatedComponent but also updates the
children
> of the other components in an unintended way.
>
> Instead of
>
> 1
>   11  12  13
> 2
>   21  22  23
> 3
>   31  32  33
> x
>   x    y    z
>
> I get
>
> 1
>   11  11  11
> 2
>   22  22  22
> 3
>   33  33  33
> x
>   x    y    z
> .
>
> The strange thing is that all the children of Repeater of the
> RepeatedComponent get the same repeaterIndex as the RepeatedComponent
> itself.
>
> Thanks in advance for any hints. Any other solution or even a
workaround
> would help me.
>
>
> Code:
>
> [RepeatedComponent.mxml]
> <?xml version="1.0" encoding="utf-8"?>
> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml";>
>     <mx:Object id="dataProvider"/>
>     <mx:Label text="{dataProvider.label}"/>
>     <mx:Repeater id="r" dataProvider="{dataProvider.data}"
width="100%"
> recycleChildren="true">
>         <mx:Label text="label: {r.currentItem.label}"/>
>     </mx:Repeater>
> </mx:VBox>
>
> [Test.mxml]
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
> layout="absolute" xmlns:local="*">
>     <mx:Script>
>         <![CDATA[
>             import mx.collections.ArrayCollection;
>
>             [Bindable]
>             private var dataProvider:ArrayCollection = new
> ArrayCollection([
>                 {label:"1", data:new
> ArrayCollection([{label:"11"},{label:"12"},{label:"13"}])},
>                 {label:"2", data:new
> ArrayCollection([{label:"21"},{label:"22"},{label:"23"}])},
>                 {label:"3", data:new
> ArrayCollection([{label:"31"},{label:"32"},{label:"33"}])}
>                 ]);
>
>             private function addItem():void {
>                 dataProvider.addItem({label:"x", data:new
> ArrayCollection([{label:"x"},{label:"y"},{label:"z"}])});
>             }
>         ]]>
>     </mx:Script>
>     <mx:VBox>
>         <mx:Repeater id="r" dataProvider="{dataProvider}" width="100%"
> recycleChildren="true">
>             <local:RepeatedComponent dataProvider="{r.currentItem}"/>
>         </mx:Repeater>
>         <mx:Button label="ClickMe" click="addItem()"/>
>     </mx:VBox>
> </mx:Application>
>

Reply via email to