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
Highlighted
Contributor
Posts: 17
Registered: ‎07-31-2013
My Device: Q10
My Carrier: T-Mobile
Accepted Solution

Problem sorting a List

Hi,

 

i want to sort a list but it doesn't work. 

the list item data should be the sorting key.

i tried to set a groupdatamodel and set the sortingkey to listitemdata.status but it was not working

has someone had a similar issue and could help me out?

this is my code:

 

ListView {
id: list objectName: "list" layout: StackListLayout { } listItemComponents: [ ListItemComponent { type: "header" Header { visible: false } }, ListItemComponent { type: "item" StandardListItem { title: ListItemData.name description: ListItemData.description status: ListItemData.status } } ] 
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Problem sorting a List

We all know what a ListView looks like, why don't you actually post the code that tried to use the GroupDataModel with a sorting key?


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Contributor
Posts: 17
Registered: ‎07-31-2013
My Device: Q10
My Carrier: T-Mobile

Re: Problem sorting a List

[ Edited ]

actually i want to know if there is a way to add the Groupdatamodel inside the listview and get access to the listitemdata.status.

so that i can set the status as sorting key, because the status is a timestamp string and i want to get a chronically order

Developer
Posts: 543
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....
My Carrier: Telekom Slovakia

Re: Problem sorting a List

ListItemData.status == sortingKeys: ['status']


If helped give a like. If your problem was solved mark the post as "Solution"
Portfolio: BlackBerry Nokia
Social: Twitter | Facebook
About Me / Blog DevPDA | Blog
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Problem sorting a List

[ Edited ]

No sorting is done as QVariant comparisons so you will need to roll your own.

 

Actually QVariant can encapsulate QDate and QDateTime so if you can convert your timestamp to that format it should work.


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 543
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....
My Carrier: Telekom Slovakia

Re: Problem sorting a List

[ Edited ]

I just shortened answer

If guy need sorting by the status key of GroupDataModel item. for example:
{status: status} in Json object then need to set sorting keys of GroupDataModel to ['status']

 

@BBSJdev

Ok, I will edit featured posts



If helped give a like. If your problem was solved mark the post as "Solution"
Portfolio: BlackBerry Nokia
Social: Twitter | Facebook
About Me / Blog DevPDA | Blog
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Problem sorting a List

@Benecore You can edit a posting if you need to amend or add anything to it, no need to post a new message.


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Contributor
Posts: 17
Registered: ‎07-31-2013
My Device: Q10
My Carrier: T-Mobile

Re: Problem sorting a List

[ Edited ]

my QMap look like this and i want the lastUpdate as sortig key.

 

QMap(("weather", QVariant(QVariantList, (QVariant(QVariantMap, QMap(("citydocid", QVariant(QString, "") ) ( "id" ,  QVariant(qlonglong, 94) ) ( "city" ,  QVariant(QString, "test") ) ( "lastUpdate" ,  QVariant(QString, "2013-1008T17:23:39.154Z") ) ) ) ) )

 

 

but how can i get access to lastupdate?

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Problem sorting a List

What is your dataModel?
Is it a QMap or did it originally come from xml,json,sql?
If so can you post a snippet of that as well?

If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Contributor
Posts: 17
Registered: ‎07-31-2013
My Device: Q10
My Carrier: T-Mobile

Re: Problem sorting a List

"weather": [
    {
      "id": 94,
      "city": "test",
      "lastUpdate": "2013-10-08T17:23:39.154Z",
      "citydocid": "",
    },
    {
      "id": 98,
       "city": "test1",
      "lastMessagePreview": "hello",
      "lastMessageTime": "2013-10-08T17:27:59.745Z",
      "citydocid": "",
    }
  ]

data model is json 

that is what the json format looks like.