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
jbadwal
Posts: 52
Registered: ‎04-22-2012
My Device: Z10
Accepted Solution

Preventing ListView item selection during multi select

How do you prevent a user from selecting specific items during a multi select. Can you use the MultiSelectHandler to do this ?

 

I have basically two types of items. Cached and Uncached.  When the user is performing a Multi Select on a Cached item.. I only want them selecting other Cached items.  Likewise if the user is performing a Multi Select on an Uncached item.. I only want them selecting other Uncached items.  

 

Is there anyway to do this?  Been googling for half an hour and cant find anything related to this use case. 

Developer
jbadwal
Posts: 52
Registered: ‎04-22-2012
My Device: Z10

Re: Preventing ListView item selection during multi select

bump

Developer
jbadwal
Posts: 52
Registered: ‎04-22-2012
My Device: Z10

Re: Preventing ListView item selection during multi select

bump.

 

Just trying to figure out if its possible to prevent selection (during multiple select phase) of specific ListView items or ListItemComponents. 

Developer
jbadwal
Posts: 52
Registered: ‎04-22-2012
My Device: Z10

Re: Preventing ListView item selection during multi select

up

Developer
jbadwal
Posts: 52
Registered: ‎04-22-2012
My Device: Z10

Re: Preventing ListView item selection during multi select

back to the top

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

Re: Preventing ListView item selection during multi select

In the onTriggered() slot of the ActionItem you are able to read the currently selected items using selectionList() then determine whether you want to clear the item or not dependent on your grouping rules.


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

Developer of stokLocker, Sympatico and Super Sentences.
Developer
jbadwal
Posts: 52
Registered: ‎04-22-2012
My Device: Z10

Re: Preventing ListView item selection during multi select

Since I use a custom list item I went about this a bit differently. My CustomListItem implements a ListItemListener. I implemented the select method as such. 

 

 

void CustomStandardListItem::select(bool select) {
	bb::cascades::ListItemListener* lil = static_cast<bb::cascades::StandardListItem*>(m_sli);
	bb::cascades::ListView * view = qobject_cast<bb::cascades::ListView*>(this->parent());

	if (view->multiSelectHandler()->isActive()) {
		bool isCached = view->property("isMultiSelectTypeCached").toBool();

		if (m_cachedImageView->isVisible() && isCached) { // is cached.. allow selection of other cached objects only
			lil->select(select);
		}
		else if (!m_cachedImageView->isVisible() && !isCached) { // is not cached.. allow selection other cached objects only
			lil->select(select);
		}
	}
	else {
		lil->select(select);
	}
}

 

 The dynamic property "isMultiSelectTypeCached" is just a bool on the ListView that gets set based on the type of ListItemComponent. This could just have been the ListItemComponent type as well.