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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Cascades Development

Reply
Contributor
xelexdu
Posts: 13
Registered: ‎02-08-2013
My Carrier: Rogers

GroupDataModel ArrayDataModel

ListView* list = m_root->findChild<ListView*>("List");
ArrayDataModel *model = new ArrayDataModel;

 

for(int count = 0; count < 2; count ++)

{
data1 = jsonva.toMap()["Items"].toList()[count].toMap()["Caption"];
data2 = jsonva.toMap()["tems"].toList()[count].toMap()["Description"];
data3 = jsonva.toMap()["Items"].toList()[count].toMap()["Date"];

map["Caption"] = data1;

map["Description"] = data2;
map["Date"] = data3;
model->insert(map);

}

list->setDataModel(model);

 

With the above code, I can only see caption on my listview whereas Description and Date are missing. Any help ?

 

When I tried GroupDataModel instaed of ArrayDataModel, it seems to work as expected but I need unsorted data models such as ArrayDataModel.

Please use plain text.
Developer
Zmey
Posts: 883
Registered: ‎12-18-2012

Re: GroupDataModel ArrayDataModel

Hi,

Is this a copy-pasted code?
toMap()["tems"] <--- seems to be a typo here

Could you try assigning predefined strings to map[] to exclude the possibility that the data wasn't retrieved successfully?

map["Description"] = QVariant(QString("Test")); etc

If this won't help please show the QML too.
Please use plain text.
Contributor
xelexdu
Posts: 13
Registered: ‎02-08-2013
My Carrier: Rogers

Re: GroupDataModel ArrayDataModel

[ Edited ]

Container{
id: listViewItem
visible: true
background : Color.White
layout : DockLayout {
}
ListView {
verticalAlignment : VerticalAlignment.Center
id: List
objectName: "List"
listItemComponents: [
ListItemComponent {
type: "item"
StandardListItem {
title: ListItemData.Caption
description: ListItemData.Description
status: ListItemData.Date

}
}
] // end of listItemComponents list
}
}

 

Its a copy-pasted code. I assigned a predifined strings and It still didnt work. I am  able to print data I retrieve on  a log file. So data is not a problem. Am I missing something on QML file?

Please use plain text.
Developer
strobejb
Posts: 178
Registered: ‎10-15-2012
My Carrier: Orange

Re: GroupDataModel ArrayDataModel

IIRC the ArrayDataModel uses an empty string for the itemType. So your ListView thinks that there are no items with the "item" type.

You can use the itemType() callback in QML to force each listitem to have a specific type:

ListView {

function itemType(data, indexPath) {
return (indexPath.length == 1 ? 'header' : 'item');
}

}
Please use plain text.