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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Highlighted
Developer
Posts: 188
Registered: ‎09-03-2012
My Device: Blackberry 10
Accepted Solution

Cannot specify sub data in header title

Hello,

 

It seems like the title for the Header cannot use sub item similar to the example below. The item has to the first on the sorting list.

 

Does anyone have a work around?

 

Thanks!

 

 

ListItemComponent {
                     type: "header"                         
                     Header {
                         title: ListItemData.group
                    }
                }

Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Cannot specify sub data in header title

I'm not sure that's sufficient information for anyone to know what you mean. Which DataModel subclass are you using with this? I've certainly used code that looks like the above with an ArrayDataModel, for what it's worth. Maybe a bit more code shown would help us?

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: 188
Registered: ‎09-03-2012
My Device: Blackberry 10

Re: Cannot specify sub data in header title

Sorry for not being clear.

 

Category is a map attribute with value like Category A, Category B.

 

I would like to sort base on a map attribute "type", which is integer 0 or 1. This works. However, when I specify the category from a map attribute in the header, it doesn't show anything. The only way to make it work is by taking out the .category and it will use the first sorting key, which is type

 

Doesn't work:

 

ListItemComponent {
                     type: "header"                         
                     Header {
                         title: ListItemData.category // Supposed to show Category A and Category B but it is empty
                    }
                },

...

attachedObjects: [
                // A GroupDataModel is used for presenting the SQL data. All set up is done here
                // except for the actual population of the model, which is done in C++.
                GroupDataModel {
                    id: groupModel
                    grouping: ItemGrouping.ByFullValue    
                    //sortedAscending: false               
                    sortingKeys: [
                        "type", "index"                       
                    ]

}

 

 

 

Work but only show 0 or 1 on the header

 

ListItemComponent {
                     type: "header"                         
                     Header {
                         title: ListItemData  // Show 0 or 1 header
                    }
                },

...

attachedObjects: [
                // A GroupDataModel is used for presenting the SQL data. All set up is done here
                // except for the actual population of the model, which is done in C++.
                GroupDataModel {
                    id: groupModel
                    grouping: ItemGrouping.ByFullValue    
                    //sortedAscending: false               
                    sortingKeys: [
                        "type", "index"                       
                    ]

}

 

 

Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Cannot specify sub data in header title

I believe this is by design.  Note in the docs for GroupDataModel, where it says "For the headers, GroupDataModel::data() returns a QVariant containing the value that all children of that header have in common. In the illustration below, GroupDataModel::data() has returned a QVariant containing the QString "A" for the first header, "B" for the second header, and so on."


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: 188
Registered: ‎09-03-2012
My Device: Blackberry 10

Re: Cannot specify sub data in header title

Thanks Peter!