First time here? Check out the FAQ!
I have a listbox grid implemented with multiple=true and set all rows selected by default.
The requirement is to get the row/listitem unselected by end user. The selectedItems is giving list of selected items, but is there is a straight way to get the item currently unselected?
<listbox sclass="listbox" span="true" model="@load(vm.myModel)" multiple="true" checkmark="true" selectedItems="@bind(vm.selectedItemList)" onSelect="@command('itemSelected')" selectedItem="@bind(vm.currentSelectedItem)">
selecteItem is returning the first item in the list. itemSelected action too is giving only those items selected.
Listbox.getSelection()
returns you a Set
. You can put your original complete data model in a Set
, too. Then, find the difference of these 2 sets, you get the unselected data set.
The simplest way is:
completeSet.removeAll(selectionSet);
For other ways, you can refer to https://stackoverflow.com/questions/18644579/getting-the-difference-between-two-sets
Thanks for your quick reply @hawk. I thought there might be an existing feature to get the unselected items something like selectedItem. Now I have used removeAll and the problem is resolved.
Asked: 2019-12-04 11:32:32 +0800
Seen: 12 times
Last updated: Dec 07
ZK Listbox Selectitems issue with Set
How to stop a bug from a listbox?
Cannot Change Listbox Header color & Background
Keyboard navigation in listbox
Can not display data in listbox
listbox with nonSelectabletags inplace new listitem
Input invoice using inline listbox
Change color to hover listitem listbox zk7 + Atlantic Theme
Listbox with autopaging causes constant row flickering
zk listbox getItems() returns null for item.getValue() if not scrolled fully