<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
width="100%"
height="100%"
creationComplete="init()"
>
<mx:Panel id="main"
width="100%"
height="100%"
title="Testing representing complex structure in nested repeater"
>
<mx:Repeater id="rpParents"
dataProvider="{this.dpParent}">
<mx:HBox width="100%">
<mx:Text id="txtParentName"
width="100%"
paddingLeft="100"
text="{rpParents.currentItem.name}"
/>
<mx:Button id="btnAddChild"
label="Add a child to this parent node"
click="this.handleAddChildClick(event);"
/>
</mx:HBox>
<mx:Repeater id="rpChildren"
dataProvider="{
rpParents.currentItem.children}"
>
<mx:Text id="txtChildName"
width="100%"
paddingLeft="200"
text="{
rpChildren.currentItem.name}"
/>
</mx:Repeater>
</mx:Repeater>
<mx:ControlBar
width="100%"
horizontalAlign="right">
<mx:Button id="btnClearParents"
label="Clear all parents"
click="this.dpParent = new ArrayCollection();"
/>
<mx:Button id="btnAddParentNode"
label="Add a new parent node"
click="handleAddParentClick();"
/>
</mx:ControlBar>
</mx:Panel>
<mx:Script>
<![CDATA[
import
mx.collections.ArrayCollection;
import mx.core.UIComponent;
[Bindable]
public var dpParent:ArrayCollection;
public function init() : void
{
dpParent = new ArrayCollection();
}
public function handleAddParentClick():void
{
var newParent:Object = new Object();
newParent.name
= "Parent number " + (dpParent.length + 1);
newParent.children = new ArrayCollection();
this.dpParent.addItem(newParent);
}
public function handleAddChildClick(event:MouseEvent):void
{
var parent:Object = UIComponent(event.currentTarget).getRepeaterItem();
var newChild:Object = new Object();
newChild.name = "Child number " + (ArrayCollection(parent.children).length + 1);
ArrayCollection(parent.children).addItem(newChild);
}
]]>
</mx:Script>
</mx:Application>
Thanks,
Jaime
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
| Software development tool | Software development | Software development services |
| Home design software | Software development company |
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe
__,_._,___

