Flex repeater control part 2
Return back again.
In this section we’ll see how to retrieve repeater item and its data.
Lets have our example…
<mx:VBox id="box" height="100%" width="100%">
<mx:Spacer height="10"/>
<mx:Repeater id="r" dataProvider="{xmlColMenu}" startingIndex="0" recycleChildren="true">
<mx:LinkButton id="idx" label="{r.currentItem.name}" click="{clbClick(event);}" styleName="RightLink"/>
<mx:Repeater id="s" dataProvider="{r.currentItem.link}"
startingIndex="0" recycleChildren="true">
<mx:LinkButton id="idy" label="{s.currentItem.name}"
click="{clbClick(event);}" fontFamily="Verdana"
fontSize="9" fontStyle="normal" fontWeight="normal"
textSelectedColor="#03598B" textRollOverColor="#47A318" disabledColor="#47A318" height="15"
color="#666666" themeColor="#FFFFFF"/>
</mx:Repeater>
</mx:Repeater>
</mx:VBox>
Now we will write clbClick event for the repeater item. Indeed, your event handler will be written in <mx:Script> block.
/**
* Navigation item click event.
* @param event of type MouseEvent.
*/
private function clbClick(event:MouseEvent):void
{
trace(event.target.getRepeaterItem().id);
}
If you use getRepeaterItem(), it gives you access to the data item that you’d set earlier while repeating the item.
<mx:LinkButton id="idx" label="{r.currentItem.name}" click="{clbClick(event);}" styleName="RightLink"/>
In my case, I need to access id. You may have different data.
In next section we’ll check how to update repeater control dynamically. Till then c. y.
Related posts:
- Flex repeater control part1 Repeater control is very useful but little bit complex to...
Related posts brought to you by Yet Another Related Posts Plugin.
Date: April 15th, 2010 @ 05:25
Categories: Uncategorized
Recent Comments