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
Developer
Posts: 587
Registered: ‎04-01-2009
My Device: Z10, PlayBook
My Carrier: NA
Accepted Solution

ListView with GridListLayout Won't Display Items

I can easily create a ListView that displays its items.


Here's the XML:

 

<root>
    <header title="Android">
        <item  name="NAME"/>
    </header>
    <header title="Blackberry">
        <item  name="NAME"/>
    </header>
    <header title="iOS">
        <item  name="NAME"/>
    </header>
</root>

 And here's the QML:

 

            ListView {
                dataModel: XmlDataModel {
                    source: "asset:///test.xml"
                }
                
                listItemComponents: [
                    ListItemComponent {
                        type: "header"
                        Header {
                            title: ListItemData.title
                        }
                    },
                    ListItemComponent {
                        type: "item"
                        Label {
                            text: ListItemData.name
                        }
                    }
                ]
            }

 The result looks like this:

 

Capture.PNG

 

But what I really want are the items to be displayed in a grid. To do that, I set the layout property of the ListView to a GridListLayout:

 

                layout: GridListLayout {
                }

 

When I do that, it no longer displays any items, only the headers:

 

Capture.PNG

 

What am I doing wrong?

 

Ultimately I was trying to get this working using a custom LitemItemProvider that used images for the items, but again, it would only display the headers.  So, I've simplified my example as much as I can above to try and pinpoint the problem.  I'm not sure how to make the example any simpler.  I am able to get my original code working fine even with the GridListLayout if I don't enable grouping -- as soon as I enable grouping (so that the data has headers and items), it starts behaving like this.

 

Is the grid view incompatible with grouping?!  The native pictures app does grouping with a grid view, and I'm trying to emulate that.  Super confused.

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

Re: ListView with GridListLayout Won't Display Items

You need to set headerMode

https://developer.blackberry.com/native/reference/cascades/bb__cascades__gridlistlayout.html#propert...



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: 587
Registered: ‎04-01-2009
My Device: Z10, PlayBook
My Carrier: NA

Re: ListView with GridListLayout Won't Display Items

Sigh.  Thank you.  The documentation should really have a warning that it's required.