-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I have created a multi-selectable listbox with sort, but how can I sort items in listbox by "selected" (with checkbox checked) ??
hello tschen: I think you need to implement a comparator. takes a look at the link Sort by Comparator
finally, I solved the problems in multi-selectable listbox, I list the problems and solutions in the following:
A. add one specified flag in the binded class, for example, named "isSelected", and sort by this value.
<listheader width="64px" sort="auto(isSelected)" sortDirection="ascending" align="center" label="select sort" /><listcell> <label value="@load(isSelected)" /> </listcell>
B. selectedItem always return the first select item, but which I want is "return the item that user currently selected". I get the currently selected by compares "current selectedItems" and "prev. selectedItems".(can be used for set "isSelected" flag)
Iterator<CameraView> itr = selectedCameraViews.iterator();
while(itr.hasNext()){
CameraView itrs=itr.next();
if (!selectedCameraViewsPrev.contains(itrs)){
selectedCameraView = itrs;
break;
}
}
C. remember set selectedItem = null and isSelected = false, when user un-check the checkbox or the "sort by isSelected function" will turn into infinite loop.
I hope these works will help others.
hi mhj, thanks for the reference info. I will try, but another question is "can I sort these selected item by simply set sort="auto(somedata)" in zul file?". thanks!
tschen ( 2013-01-30 02:47:58 +0800 )edit