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

Native Development

Reply
Developer
jeswinsimon
Posts: 63
Registered: ‎11-12-2012
My Device: BB10 DevAlpha
Accepted Solution

Populate Dropdown from SQL data source

I have a datasource which pulls data from an sqlite db. How do I pass two fields from this query to a dropdown on the page. I want to create a dropdown with value and text set from this datasource

Click Accept as Solution if this post that have solved your issue(s)!
Like if you found this post useful..
Developer
Zmey
Posts: 1,523
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: Populate Dropdown from SQL data source

[ Edited ]

Hi,

 

To fetch the values you'll need to wait for onDataLoaded. 'data' parameter is a list of maps.

Some sample code of accessing the data:

http://supportforums.blackberry.com/t5/Cascades-Development/SQLite-Count-query/m-p/2477699#M27180

http://supportforums.blackberry.com/t5/Cascades-Development/DataSource-data-in-JavaScript/m-p/244171...

 

To add an option to DropDown:

attachedObjects: [
  ComponentDefinition {
    id: optionFactory
    Option {
    }
  }
]

... to add an option:

var newOption = optionFactory.createObject()
newOption.text = 'Text to add' // or a variable fetched from data source
//newOption.otherfields = ... dropdownId.add(newOption);

 


Andrey Fidrya, @zmeyc on twitter
Developer
jeswinsimon
Posts: 63
Registered: ‎11-12-2012
My Device: BB10 DevAlpha

Re: Populate Dropdown from SQL data source

Thanx. Works perfect. I wasn't aware that we have to create a separate component for Option. I was trying to create it directly within the onDataLoaded function.
Click Accept as Solution if this post that have solved your issue(s)!
Like if you found this post useful..