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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Highlighted
New Member
Posts: 1
Registered: ‎08-20-2013
My Device: Z10
My Carrier: Rogers

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
My Carrier: Koodo

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
My Carrier: Bell

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: 196
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
My Carrier: Bell

Re: bb::cascades::Picker & ArrayDataModel

Yes, I believe it works with a GroupDataModel as I said above Smiley Happy

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