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
Contributor
Posts: 23
Registered: ‎01-01-2013
My Device: BlackBerry Dev Alpha B
My Carrier: airtel

ListView ClearSelection does not work

Hi,

 

I have a ListView with a contextMenu for its ListItems as well as it has a handler for SelectionChange which navigates to next page

 

in onTriggered though I am using the clearSelection() it does not clear the previous selction and it highlights the more than 1 ListItems, it is more a UI refresh issues as the onSelectionChange takes us to right detail page for the last clicked item

 

I am using a customListItem which has a StandardListItem and one Image

 

please let me know how to fix this issue

 

Thanks,

Subhash

Developer
Posts: 251
Registered: ‎11-22-2011
My Device: Blackberry Playbook
My Carrier: vodafone

Re: ListView ClearSelection does not work

Same here (10.2)

 

 

   ListView {
                
                id: facesList
                
                onSelectionChanged: {
                    console.log("onSelectionChanged: " + indexPath)
                }
                
                layout: StackListLayout {
                    headerMode: ListHeaderMode.Overlay
                    orientation: LayoutOrientation.LeftToRight
                }
                
                preferredHeight: 240.0
                
                dataModel: XmlDataModel {
                    id: dataModel
                    source: "models/faces.xml"
                }
                  
                onTriggered: { 
                    console.log("onTriggered: " + indexPath)
                    facesList.clearSelection() 
                    facesList.select(indexPath); 
                } 
                
                listItemComponents: [
                    
                    ListItemComponent {
                        type: "item"
                        
                        CustomListItem {    
                            
                            preferredWidth: 240
                            preferredHeight: 240
                            highlightAppearance: HighlightAppearance.Frame

                            Container {
                                
                               
                                
                                minWidth: 240.0
                                minHeight: 240.0
                                
                                layout: DockLayout {
                                }
                                
                                ImageView {
                                    id: imageViewID
                                    imageSource: ListItemData.image
                                    preferredWidth: 230
                                    preferredHeight: 230
                                    horizontalAlignment: HorizontalAlignment.Center
                                    verticalAlignment: VerticalAlignment.Center
                                }
                            }
                        }
                    }
                ]
                scrollIndicatorMode: ScrollIndicatorMode.ProportionalBar

            }

 

 

 

does not work like descriped by lauvot.

Any idea? Thanks!

Developer
Posts: 27
Registered: ‎12-03-2013
My Device: BlackBerry Z10
My Carrier: T-Mobile

Re: ListView ClearSelection does not work

As far as i get this right, you are trying to select an item, by using the onTriggered Method?

 

If so, then try to select your item like this:

 

listView.select(indexPath, ! listView.isSelected(indexPath));

 

It should be possible to call listView.clearSelection() after selecting like above.

 

Developer
Posts: 251
Registered: ‎11-22-2011
My Device: Blackberry Playbook
My Carrier: vodafone

Re: ListView ClearSelection does not work

This is from the documentation and it works.

 

ListView {
    onTriggered: {
        clearSelection()
        select(indexPath);
    }
}

 

But clearSelection() doe's not update the UI when used together with CustomListItem. That's the problem we are talking about.

Developer
Posts: 27
Registered: ‎12-03-2013
My Device: BlackBerry Z10
My Carrier: T-Mobile

Re: ListView ClearSelection does not work

georg22 is right, the selection is acutally cleared, when using clearSelection. The highlight is simply not removed after clearing the selection.

Developer
Posts: 251
Registered: ‎11-22-2011
My Device: Blackberry Playbook
My Carrier: vodafone

Re: ListView ClearSelection does not work

   ListView {
                
                id: facesList
                
                onSelectionChanged: {
                    console.log("onSelectionChanged: " + indexPath)
                }
                
                layout: StackListLayout {
                    headerMode: ListHeaderMode.Overlay
                    orientation: LayoutOrientation.LeftToRight
                }
                
                preferredHeight: 240.0
                
                dataModel: XmlDataModel {
                    id: dataModel
                    source: "models/faces.xml"
                }
                
                
                onTriggered: { 
                    console.log("onTriggered: " + indexPath)
                    facesList.clearSelection() 
                    facesList.select(indexPath); 
                } 

                listItemComponents: [

                    ListItemComponent {
                        type: "item"
                        
                        Container {

			    id: itemRoot
                            minWidth: 240.0
                            minHeight: 240.0

                            layout: DockLayout {
                            }

                            ImageView {
                                id: imageViewID
                                imageSource: ListItemData.image
                                preferredWidth: 230
                                preferredHeight: 230
                                horizontalAlignment: HorizontalAlignment.Center
                                verticalAlignment: VerticalAlignment.Center
                            }
                           
                            ImageView {
                                preferredWidth: 240
                                preferredHeight: 240
                                opacity: itemRoot.ListItem.selected || itemRoot.ListItem.active ? 1.0 : 0.0
                                imageSource: "asset:///images/item_frame.amd"
                            }
                            ImageView {
                                preferredWidth: 240
                                preferredHeight: 240
                                opacity: itemRoot.ListItem.selected ? 1.0 : 0.0
                                imageSource: "asset:///images/item_frame_bold.amd"
                            }
                            
                        }
                  
                    }
                ]


            }

 

This is the 10.0 "old fashioned" method I use to simulate the desired behavior without CustomListItem and it works fine.

 

But CustomListItem seems to be broken...   :-(

Developer
Posts: 1,746
Registered: ‎04-08-2010
My Device: Passport Silver, PRIV
My Carrier: Telekom.de, O2, Vodafone

Re: ListView ClearSelection does not work


georg22 wrote

 

But CustomListItem seems to be broken...   :-(


you should open an issue

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development native Mobile Business Apps
BlackBerry 10 | Qt Mobile (Android, iOS)
Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org
mobile-development: http://appbus.org Twitter: @ekkescorner
Developer
Posts: 251
Registered: ‎11-22-2011
My Device: Blackberry Playbook
My Carrier: vodafone

Re: ListView ClearSelection does not work

Thanks guys.

I was hoping I missed something. Seems to be a bug.

I will open an issue.

Developer
Posts: 1,746
Registered: ‎04-08-2010
My Device: Passport Silver, PRIV
My Carrier: Telekom.de, O2, Vodafone

Re: ListView ClearSelection does not work


georg22 wrote:

Thanks guys.

I was hoping I missed something. Seems to be a bug.

I will open an issue.


yep

verified this - it's not working for Custom ListItem

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development native Mobile Business Apps
BlackBerry 10 | Qt Mobile (Android, iOS)
Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org
mobile-development: http://appbus.org Twitter: @ekkescorner
Developer
Posts: 251
Registered: ‎11-22-2011
My Device: Blackberry Playbook
My Carrier: vodafone

Re: ListView ClearSelection does not work

... and it's already a reported issue: BBTEN 1903. Lets hope they fix it soon. Cheers.