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
Posts: 154
Registered: ‎02-01-2009
My Device: Torch, PlayBook and Dev Alpha
My Carrier: SFR
Accepted Solution

ListView and unselectable item

I'd like to make in sort that some items are unselectable by the user.

 

In particular, I use a ListView with GroupDataModel and cascades create virtual item on grouping.

It's an issue with the multiselect function or selectall.

 

Nicolas

 

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: ListView and unselectable item

The simplest way is to just do a check in the onSelectionChanged slot and deselect it if not selectable.

 

e.g.

 

    onSelectionChanged: {
        if (indexPath == 0)
            select(indexPath, false);            // Don't allow selection
     }

 The check you do should obviously depends on your criteria but this one would stop the first item being selected.


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Highlighted
Developer
Posts: 154
Registered: ‎02-01-2009
My Device: Torch, PlayBook and Dev Alpha
My Carrier: SFR

Re: ListView and unselectable item

[ Edited ]

Thank you very much, I'm going to use your workaround. So finally,

 

- in the ListView component :

onSelectionChanged: {
  if (indexPath.lenght == 1)
    select(indexPath, false); // Don't allow selection
}

 

- in the ListItemComponent :

ListItem.onSelectionChanged: {
  if (ListItem.indexPath.length == 1)
    ListItem.view.select(ListItem.indexPath, false);
}

 

 

Nicolas