02-21-2011 05:23 PM
I have the following object:
public var ID : Int; public var FirstName : String; public var LastName : String;
And then create Array of these objects...
And then add the array to a DataProvider:
var dp:DataProvider = new DataProvider(); dp.setItems(contactArray);
and then set this data provider as a source for a DropDown:
dropDown.dataProvider = dp;
the problem is the drop down is displayed empty.
How do i tell the drop down which property of the object in the array to use for display and which for ID?
02-21-2011 05:29 PM
There is a bug in the latest SDK with this issue...perhaps this is what you are experiencing
See this thread HERE
02-21-2011 05:33 PM
turtle-dev wrote:
There is a bug in the latest SDK with this issue...perhaps this is what you are experiencing
See this thread HERE
Thanks but I am not using prompt, therefore based on what is described in that thread this should not apply?
02-21-2011 07:57 PM
hey p3pp3r,
there is no way to change what field is used when the drop down displays it's text. what i do whenever i have an object, i add a .label property to it. only label properites are used when displaying data in all lists and drop down menus. so just add a label property to your object and set that to what you want to show up on the list. good luck!
02-21-2011 08:55 PM
JRab - thanks .. but wow.. i will have to add .label property to all my entity objects... and then i may want to display different field in different places.. so this workaround will not take me too far.. This seems to be very basic requirement for any dropdown.. unless i am missing something here...?
02-21-2011 09:04 PM - edited 02-21-2011 09:05 PM
I'm using an SQLite database, however I use this to fill the dropdown with information from the database. fishName is a column in the table.
<s:DropDownList id="fishPicker" dataProvider="{fishBarrel}" labelField="fishName" prompt="Choose a Fish"/>
02-21-2011 09:40 PM
JohnPinkerton,
Many thanks - I see you are using MXML and the MXML control allows you to specify labelField. This is exactly what I am missing in AS3 since my app is entirely written in ActionScript...
I followed JRab's suggestion and ammended some of my objects to have "dynamic" property called .label and included the following in the get method of this property:
public function get label():String
{
return LastName + ", " + FirstName;
}
but no way to specify it in the DropBox itself... The DropDown class in ActionScript does not have labelField property...
02-21-2011 09:41 PM
Ah, gotcha, missed that part. Sorry.