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
New Developer
david_schwartz_bb
Posts: 137
Registered: ‎02-04-2010
My Device: Tour 9630
Accepted Solution

List of Objects

Is there a list that can take an object? For example, I have a Notes Dictionary object with title & description. I want to pass it to a List. When the user clicks on the list row & can get the note description from the object.

Even a way to set the display text & underlying key would suffice.

thanks

Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: List of Objects

Lists, Dropdowns, etc all can take a list of objects.  It is all given to the dataprovider of the control.  for example:

 

var ar : Array = [ { label: 'circles', blob : 12345 },
                   { label: 'squares', blob : 3456f } ];

this.mylist.dataProvider = new DataProvider( ar );

 

You can put anything in the array given to the data provider.  Then, upon selection you can access any of those attributes by:

 

var blob : int = int( this.mylist.selectedItem.blob );

 

Or what ever type your attribute is.

 

The 'label' attribute is required to see it in the list.  If you have a custom renderer for the list, you can display other information in the list including other text, images, etc.

 

Hope that helps.

Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: List of Objects

[ Edited ]

David, the qnx.ui.listClasses.List widget takes a DataProvider which wraps an Array of objects.  The "label" properties in the objects are what get displayed, but you can retrieve the selected Array entry (i.e. one of those objects) and get any other properties out of it when the user selects an item.  That sounds like what you need.

 

See, for example, jtegen's response in this thread where he shows how to store an "id" property along with the label.


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!