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: 13
Registered: ‎02-08-2013
My Device: Z10
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.

Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

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.

Andrey Fidrya, @zmeyc on twitter
Highlighted
Contributor
Posts: 13
Registered: ‎02-08-2013
My Device: Z10
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?

Developer
Posts: 293
Registered: ‎10-15-2012
My Device: bb10 developer
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');
}

}