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
New Member
Posts: 1
Registered: ‎08-20-2013
My Device: Z10

bb::cascades::Picker & ArrayDataModel

I am trying to load a picker with a JSON object, however all the examples I have found online in the documentation reference the XmlDataModel.

Even mimicing the structure of the XML in JSON I cannot get the data to load into the picker. I have a code snippet (below) with some partial functionality, the number of rows and columns are correct however the pickerItemData object is 'undefined' at the root level, which means I can't display any of the data I use to create the row.

Any insight into what I'm missing here would be beneficial. Thanks in advance.

 

import bb.cascades 1.2

Page {
    Container {
        leftPadding: 24.0
        rightPadding: 24.0
        topPadding: 12.0
        bottomPadding: 12.0
        controls: [
            Picker {
                expanded: true
                dataModel: ArrayDataModel {
                    id: pickerDataModel
                }
                pickerItemComponents: PickerItemComponent {
                    StandardPickerItem {
                        id: rootComponent
                        title: pickerItemData.name
                        onCreationCompleted: {
                            console.log("PID: " + pickerItemData);
                            console.log("This: " + rootComponent);
                            console.log("Parent: " + parent);
                        }
                    }
                }
                onCreationCompleted: {
                    var column = [ {"name":"Test 1"}, {"name":"Test 2"}, {"name":"Test 3"}, {"name":"Test 4"} ];
                    pickerDataModel.append([ column, column, column ])
                }
            }
        ]
    }
}

Developer
Posts: 38
Registered: ‎12-06-2011
My Device: Playbook 64GB, Curve 9360, BB Z10 LE

Re: bb::cascades::Picker & ArrayDataModel

I am having the same problem. Did you find a solution or anyone else have a solution?

Retired
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30

Re: bb::cascades::Picker & ArrayDataModel

Try GroupDataModel rather than an ArrayDataModel. I'm not sure you can just stick JSON into an ArrayDataModel like that.

 

https://developer.blackberry.com/native/documentation/cascades/device_platform/data_access/working_w...

Paul Bernhardt
Application Development Consultant
BlackBerry
@PBernhardt

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker
Developer
Posts: 193
Registered: ‎12-14-2009
My Device: Not Specified

Re: bb::cascades::Picker & ArrayDataModel

Has anyone figured a way to use Json datamodel with a Picker yet?

Retired
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30

Re: bb::cascades::Picker & ArrayDataModel

Yes, I believe it works with a GroupDataModel as I said above :smileyhappy:

Paul Bernhardt
Application Development Consultant
BlackBerry
@PBernhardt

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker