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

Posts: 48
Registered: ‎10-11-2012
My Device: Z10
My Carrier: none

bb::cascades::Picker & GroupDataModel

1)The standard way if you want to show several columns in the Picker is to use several PickerItemComponent. Each of PickerItemComponents would describe its part of data for selection.


2)Another task in using Picker is to use sorted list of options for selecting. The typical recommendations for this is to use GroupDataModel. But if you will try it, you will get something strange and not expected.


So, what you will get and how to use it ? Unfortunately I did not found any information about this and everything was got from experiments.


The results of experiments if you will use GroupDataModel with Picker :

1) If you will setGrouping(ItemGrouping::None) for GroupDataModel you will get no visible data in your picker

2) If you will sort your data and default Grouping mode you will get as many columns in your Picker as many groups would be found in your data. As example if your data has field "name" and values "Mark", "Mike", "Andrew", so sorting by this field would get two columns in the Picker. First column with one value "Andrew" and the second column with values "Mark" and "Mike". Each row in each column would use the same visible form of PickerItemComponent with type="item" (because this type is returned by GroupDataModel, so you have to define such one component).

3) If you want to have only one column with sorted data you have to add one field with same data to each data entry for GroupDataModel and make sorting by this field firstly, this would create one group, so Picker will show only one column and you will have data sorted because you would define your sorting field as a second parameter for sorting in your GroupDataModel.


If some one knows where is a normal documentation for using different data models in the Picker, please leave link in comment.

Also I would like to know about another ways to show sorted dynamical data for Picker, so if you have your idea you are welcome !