0

how can I sort "selected" items in listbox? [closed]

asked 2013-01-29 12:46:08 +0800

tschen gravatar image tschen
1 1

I have created a multi-selectable listbox with sort, but how can I sort items in listbox by "selected" (with checkbox checked) ??

delete flag offensive retag edit

The question has been closed for the following reason "the question is answered, right answer was accepted" by ashishd
close date 2013-02-04 01:48:10

Comments

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

2 Answers

Sort by ยป oldest newest most voted
2

answered 2013-01-29 14:19:41 +0800

mhj gravatar image mhj flag of Brazil
806 1 7

hello tschen: I think you need to implement a comparator. takes a look at the link Sort by Comparator

link publish delete flag offensive edit
0

answered 2013-02-01 09:40:10 +0800

tschen gravatar image tschen
1 1

updated 2013-02-01 09:49:15 +0800

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.

link publish delete flag offensive edit

Comments

Please accept answer and close the question

sjoshi ( 2013-02-01 09:42:48 +0800 )edit

how to accept answer and close the question??

tschen ( 2013-02-01 09:55:17 +0800 )edit

Cllck on the right click button so that you can accept answer and below question you can see close it will close your question

sjoshi ( 2013-02-01 11:00:59 +0800 )edit

Question tools

Follow
2 followers

RSS

Stats

Asked: 2013-01-29 12:46:08 +0800

Seen: 60 times

Last updated: Feb 01 '13

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More