Repeater not working fine when passed a dataprovider (array) having a single element
- by baltusaj
I am using a Repeater in an Accordian which does not appear to see a single element in userArray. If I add another entry to userArray then the Repeater works fine.
Thoughts??
private function currUsersServiceHandler(event:ResultEvent):void{
if (event.result.currentUsers != null)
{
if (event.result.currentUsers.user is ArrayCollection) // if more than one elements are present
{
usersArray = event.result.currentUsers.user;
}
else if (event.result.currentUsers is ObjectProxy)
{ //FIXIT usersArray populate by following line has some issue
usersArray = new ArrayCollection(ArrayUtil.toArray(event.result.currentUsers));
}
}
}
<mx:HTTPService id="currUsersService" url="currUsers.xml" result="currUsersServiceHandler(event)"/>
<mx:Accordion includeIn="UserList" x="10" y="10" width="554" height="242" >
<mx:Repeater id="rep" dataProvider="{usersArray}">
<mx:Canvas width="100%" height="100%" label="{rep.currentItem.firstName}" >
<mx:HBox>
<s:Label text="{rep.currentItem.firstName}"/>
<s:Label text="{rep.currentItem.lastName}"/>
<mx:/HBox>
</mx:Canvas>
</mx:Repeater>
</mx:Accordian>
Edit:
There is another thing I have just noticed i.e. that the accordian does show a single tab (when Array has a single element) but it's not labeled with the first name which I am setting. If I enter another user, two tabs appear and both are labeled with names I am setting. The first tab appears labeled too then.