- Mark as New
- Follow
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report
Hello,
I am trying to use the customFields in the user descriptor as additional data to be bound to a component in an item renderer. I have some data that is tied to every user in the roster and I would like it to be displayed and modified at runtime based on user interaction. Here is the code I wrote for setting the customFields.
protected function eGamingSession_creationCompleteHandler(event:FlexEvent):void
{
// TODO Auto-generated method stub
for(var i:int=0;i<eGamingSession.userManager.userCollection.length;i++)
{
eGamingSession.userManager.userCollection.getItemAt(i).customFields['score'] = 10;
trace("Value of stepper is: "+eGamingSession.userManager.userCollection.getItemAt(i).customFields.score);
}
}
Then in the item renderer, the code is as follows:
<s:List id="userList"
dataProvider="{eGamingSession.userManager.userCollection}"
labelField="displayName"
width="100%" height="100%">
<s:itemRenderer>
<fx:Component>
<s:ItemRenderer>
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
// TODO Auto-generated method stub
override public function set data(value:Object):void {
super.data = value;
// Check to see if the data property is null.
if (value== null)
return;
// If the data property is not null,
// set the CheckBox control appropriately..
if (value.customFields.score == 10) {
userStepper.value = 10;
}
else {
userStepper.value = 0;
}
}
]]>
</fx:Script>
<s:HGroup width="100%">
<s:Label text="{data.displayName}" paddingTop="5" width="60%"/>
<s:NumericStepper id="userStepper" width="10%" value="{data.customFields['score']}"/>
</s:HGroup>
</s:ItemRenderer>
</fx:Component>
</s:itemRenderer>
</s:List>
The problem is I don't see the customFields property set in the item renderer. I see it in the creationCompleteHandler, but it is not passed to the item renderer. Is the customFields not intended to be used this way?
Will appreciate any insight,
Thanks!
Views
Replies
Total Likes