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
gpatton
Posts: 193
Registered: ‎12-29-2010
My Device: Bold 9900
Accepted Solution

Headers are clickable?

Hi,

 

I have a list of data that is sorted alphabetically. I have the dataModel.grouping set to ItemGrouping.ByFirstChar.

 

What this does, is that all the A's are grouped and given a header "A". All the B's are grouped with the header "B" and so on.

 

But I notice that the header itself is selectable. How can this be stopped? I don't want people clicking on the header itself? 

 

This is my code below:

 

attachedObjects: [
                GroupDataModel {
                    id: dataModel
                    sortingKeys: [
                        "name"
                    ]
                    grouping: ItemGrouping.ByFirstChar
                    sortedAscending: true
                },
                DataSource {
                    id: dataSource
                    source: "list.json"
                    onDataLoaded: {
                        dataModel.insertList(data);
                    }
                }
            ]

 

Please use plain text.
Developer
strobejb
Posts: 282
Registered: ‎10-15-2012
My Device: bb10 developer

Re: Headers are clickable?

I have never noticed that headers are selectable. What do you listItemComponents look like?
Please use plain text.
Developer
AVPTI
Posts: 64
Registered: ‎06-28-2011
My Device: BlackBerry Z10

Re: Headers are clickable?

Been wondering the same thing.

Please use plain text.
Developer
igosoft
Posts: 71
Registered: ‎09-19-2012
My Device: Z10 very soon

Re: Headers are clickable?

selectable ??

send us your QML with ListView in it

Please use plain text.
Developer
gpatton
Posts: 193
Registered: ‎12-29-2010
My Device: Bold 9900

Re: Headers are clickable?

Here is my code. Sorry for the delay.

 

Page {
        id: countryPage
        
        Container {
            
            id: countryContainer
            Container {
                id: listViewContainer
                ListView {
                    id: countryList
                    objectName: "countryList"
                    dataModel: dataModel
                    listItemComponents: [
                        ListItemComponent {
                            type: "item"
                            StandardListItem {
                                title: ListItemData.name
                            }
                        }
                    ]
                    onTriggered: {
                        var chosenItem = dataModel.data(indexPath);
                        countryView = chosenItem;
                        page = countryPageDefinition.createObject();
                        countryNav.push(page);
                    }
                }
            }
            attachedObjects: [
                GroupDataModel {
                    id: dataModel
                    //objectName: "countryDataModel"
                    sortingKeys: [
                        "name"
                    ]
                    sortedAscending: true
                    grouping: ItemGrouping.ByFirstChar
                },
                DataSource {
                    id: dataSource
                    source: "countriesCustom.json"
                    onDataLoaded: {
                        dataModel.insertList(data);
                    }
                }
            ]
        }

 

Please use plain text.
Developer
strobejb
Posts: 282
Registered: ‎10-15-2012
My Device: bb10 developer

Re: Headers are clickable?

You need to provide the ListView with a propert Header listItemComponent, in addition to the StandardListItem you already have

 

ListItemComponent {
                            type: "header"
                            Header {
                                title: ListItemData
                            }
                        }
Please use plain text.
Developer
gpatton
Posts: 193
Registered: ‎12-29-2010
My Device: Bold 9900

Re: Headers are clickable?

Tried that. Still doesn't work. The header is still clickable.

Please use plain text.
Regular Contributor
Q-T
Posts: 94
Registered: ‎12-02-2011
My Device: non-Blackberry user

Re: Headers are clickable?

Must be possible because I don't have the problem in C++  I just connect my listView's triggered and activated signals to my own slots.  The header's never never respnd to  clicks.

 

 

Please use plain text.
Developer
jeswinsimon
Posts: 63
Registered: ‎11-12-2012
My Device: BB10 DevAlpha

Re: Headers are clickable?

Found this in a sample app:

 

  

   onTriggered: {
                    
                    // To avoid triggering navigation when pressing the header items, we check so that the  
                    // index path length is larger then one (one entry would be a group under a header item).
                    if(indexPath.length > 1) {
                        // When an item is selected we push the recipe Page in the chosenItem file attribute.
                        var chosenItem = dataModel.data(indexPath);

                        // Create the content page and push it on top to drill down to it.
                        var contentpage = contentPageDefinition.createObject();

                        // Set the content properties to reflect the selected image.
                        contentpage.contentImageURL = chosenItem.URL
                        contentpage.contentDescription = chosenItem.infoText

                        // Push the content page to the navigation stack
                        nav.push(contentpage);
                    }
                }

 

Click Accept as Solution if this post that have solved your issue(s)!
Like if you found this post useful..
Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: Headers are clickable?


gpatton wrote:
But I notice that the header itself is selectable. How can this be stopped? I don't want people clicking on the header itself?

What is it about the fact they're selectable that you don't want?  Obviously you can't actually prevent a user from tapping there... but what happens when they do which is a problem for you?  Is it the fact that a long-press will invoke a context menu? Is there a highlight animation when you tap it and you don't want that? Something else?

 

Depending on what that is, there may be simpler or more complicated ways of dealing with it.


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.