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
testinz
Posts: 180
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
                    }
                }

Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

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!
Please use plain text.
Developer
testinz
Posts: 180
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"                       
                    ]

}

 

 

Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

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!
Please use plain text.
Developer
testinz
Posts: 180
Registered: ‎09-03-2012
My Device: Blackberry 10

Re: Cannot specify sub data in header title

Thanks Peter!
Please use plain text.