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
Contributor
Posts: 17
Registered: ‎09-08-2012
My Device: blackberry dev alpha
My Carrier: Airtel

problem parsing json

my first page

 

import bb.cascades 1.0
import com.rim.segmentedcontrol 1.0
NavigationPane {

id : nav
Page {
content: Container {
layout: StackLayout {
}
SegmentedControl {
id: segmented1
//-- define segmented control options here
Option { id: option1; text: qsTr("All"); value: 0; selected: true }
Option { id: option2; text: qsTr("Category 1"); imageSource: "asset:///images/picture1.png"; value: 1 }
Option { id: option3; text: qsTr("Category 2"); imageSource: "asset:///images/picture2.png"; value: 2 }
onSelectedIndexChanged: {
//-- write handler for the choosen selection here
myListModel.setFilter(segmented1.selectedValue())
}
layoutProperties: StackLayoutProperties {
horizontalAlignment: HorizontalAlignment.Fill
}
}
ListView {
id: listView

objectName: "listView"

layout: GridListLayout {
columnCount: 2
cellAspectRatio: 2
// bottomPadding: 10
}

attachedObjects: [
//-- attachedObjects is a storage for a non GUI objects like data models etc.
MyListModel { id: myListModel }
]
dataModel: myListModel
// Override DataModel::itemType() function to return "myType" value
function itemType (data, indexPath) {
return "myItem";
}
listItemComponents: [


ListItemComponent {
type: "myItem"
//-- define component which will represent list item GUI appearence
StandardListItem {

title: ListItemData.text

//status: qsTr("category: ") + ListItemData.category
imageSource: ListItemData.image
}
}
]

onTriggered: {

//console.log("selected_index: " + indexPath)
// var curr_item = dataModel.data(indexPath)
//-- show detail page for selected item
// setDetailItem(curr_item)

var page = nav.deprecatedPushQmlByString("main1.qml")

// setDetailItem(curr_item)
page.myListModel = myListModel;
page.item = chosenItem;

// page.title = segmented.selectedText;
// clearSelection();

}

layoutProperties: StackLayoutProperties {
//-- make list view to fill all parent container free arrea
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Fill
spaceQuota: 1.0
}


}



}
onCreationCompleted: {
console.log("Page - onCreationCompleted()")
myListModel.load("app/native/assets/mydata.json")
}

}

}

 

 

 

second page

 

 

 

import bb.cascades 1.0

// Details Page for a bucket item, shows the entire task contained in a bucket

// item and adds functionality for editing the item.

//ScrollView {

//scrollViewProperties {

// scrollMode: SystemDefaults.TextStyles

Page {
id: bucketPage

property variant mylistmodel
property alias title: titleBar.title
titleBar: TitleBar {
id: titleBar
visibility: ChromeVisibility.Visible
title: "Beginnier"
}
actions: [
//-- create navigation panel actions here
ActionItem {
title: qsTr("Remove Picture")
onTriggered: {
imgView2.imageSource = "asset:///images/picture1br.png";
}
}
]




Container {

layout: StackLayout {
}



Label {
layoutProperties: StackLayoutProperties {
horizontalAlignment: HorizontalAlignment.Center
}
text: MyListItem.item.text
textStyle {
base: SystemDefaults.TextStyles.BodyText
}
}
ImageView {
id: imgView2
imageSource: item.image
scalingMethod: ScalingMethod.AspectFill
layoutProperties: StackLayoutProperties {
horizontalAlignment: HorizontalAlignment.Center
}
}
TextArea {
editable: false
layoutProperties: StackLayoutProperties {
horizontalAlignment: HorizontalAlignment.Center
}
translationX: 2
// text: ListItemData.**bleep**
textStyle {
base: SystemDefaults.TextStyles.BodyText
}
}
background: Color.create("#FFffFF")
}
}

 

 

 

 

the program works but when its been navigated to next page json objects cannot be called...... just blank page...


 

2nd page was newly been added to this page... so is there anything to be done in addisional???

be thankfull if anyone sort it out...

 

 

thanks

sachin