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
Developer
Posts: 175
Registered: ‎07-19-2012
My Device: Q5, Q10, Z10, Z30, PlayBook
My Carrier: Carrier
Accepted Solution

How to enumerate through data (contents) of a populated GroupDataModel?

 
---
If you find my post helpful please "like" it and "accept as a solution"
Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: How to enumerate through data (contents) of a populated GroupDataModel?

You're probably looking for either toListOfMaps() or toListOfObjects(): https://developer.blackberry.com/cascades/reference/bb__cascades__groupdatamodel.html#tolistofmaps

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
Posts: 175
Registered: ‎07-19-2012
My Device: Q5, Q10, Z10, Z30, PlayBook
My Carrier: Carrier

Re: How to enumerate through data (contents) of a populated GroupDataModel?

Thank you for pointing me into right direction. Just for reference here is complete code to accomplish this (there may be better ways - but this is what I did):

 

QList<QVariantMap> mylist = myGroupDataModel->toListOfMaps();
for (int i = 0; i < mylist.size(); ++i) {
   QMap<QString, QVariant> myMap = mylist[i];
   QMapIterator<QString, QVariant> j(myMap);
   while (j.hasNext()) {
      j.next();
      qDebug() << "myIndex: " << i << " Key: " << j.key() << " Value: " << j.value();
   }
}

 

---
If you find my post helpful please "like" it and "accept as a solution"