I am using the Pickerlist with the AeonDesktopTheme in an application which receives JSON data async from the server. What is happening is I am attempting to use the "prompt" and load data sometime after the control has already been added to the stage (usually just a few milliseconds)
ddlWorlds = new PickerList(); ddlWorlds.width = 180; ddlWorlds.prompt = "-- Select One --"; ddlWorlds.labelField = "name"; <a href="mailto:ddlWorlds.listProperties.@itemRendererProperties.labelField">ddlWorlds.listProperties.@itemRendererProperties.labelField</a> = "name"; // The below line is used with scenario 2. Uncomment for workaround. // ddlWorlds.dataProvider = new ListCollection(); hg2.addChild(ddlWorlds); _stateMap.addMap(ddlWorlds, Event.CHANGE, ddlWorldsHandler);
If I try and just update the data when I receive it. The list fires a CHANGE event and forces selection to the first index of the list:
// If ddlWorlds has a listener, then a change event will result with the first // selected index and the prompt is removed. ddlWorlds.dataProvider = new ListCollection(_worldsList);
I was able to come up with some sort of a workaround by doing the following:
// This works, but requires the component be initialized with an // Empty List collection. ddlWorlds.dataProvider.addAll(new ListCollection(_worldsList));
The problem with Scenario 2 is that this list may change on the server and need to be updated to the UI. In Flex and various other languages, usually you can just update the dataprovider with a new object/list and the control will default to unselected and the prompt will show. Right now, to do this, It seems I have to destroy the Picker and create a new one, add an empty ListCollection, and then call addAll() on the list.
I would assume this was not your expected behavior, so I wanted to make you aware. Let me know if you need anything else from me.