Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Highlighted
Developer
Posts: 157
Registered: ‎12-16-2010
My Device: Torch 9800, PlayBook
My Carrier: I carry it myself

Display specific field in DropDown

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?

----------
If you find this post helpful please "like" it and accept as a solution.
Developer
Posts: 91
Registered: ‎01-26-2011
My Device: Torch
My Carrier: ---

Re: Display specific field in DropDown

There is a bug in the latest SDK with this issue...perhaps this is what you are experiencing

See this thread HERE

~~~~~~~~~~~~~~~~~~~~
My PlayBook Apps
Developer
Posts: 157
Registered: ‎12-16-2010
My Device: Torch 9800, PlayBook
My Carrier: I carry it myself

Re: Display specific field in DropDown

 


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?

 

----------
If you find this post helpful please "like" it and accept as a solution.
Developer
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: Display specific field in DropDown

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!

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Developer
Posts: 157
Registered: ‎12-16-2010
My Device: Torch 9800, PlayBook
My Carrier: I carry it myself

Re: Display specific field in DropDown

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...?

----------
If you find this post helpful please "like" it and accept as a solution.
Developer
Posts: 350
Registered: ‎01-21-2011
My Device: Curve 8900 (Personal) / Bold 9650 (Work)
My Carrier: Regional

Re: Display specific field in DropDown

[ Edited ]

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"/>

 

 

Developer
Posts: 157
Registered: ‎12-16-2010
My Device: Torch 9800, PlayBook
My Carrier: I carry it myself

Re: Display specific field in DropDown

JohnPinkerton,

 

 

 

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...

 

 

----------
If you find this post helpful please "like" it and accept as a solution.
Developer
Posts: 350
Registered: ‎01-21-2011
My Device: Curve 8900 (Personal) / Bold 9650 (Work)
My Carrier: Regional

Re: Display specific field in DropDown

Ah, gotcha, missed that part. Sorry.