my dog learned polymorphism*
The moose likes Beginning Java and the fly likes sorting selected checkboxes to the top of table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "sorting selected checkboxes to the top of table" Watch "sorting selected checkboxes to the top of table" New topic
Author

sorting selected checkboxes to the top of table

arjun Pal reddy
Greenhorn

Joined: Apr 30, 2011
Posts: 3
Hi
I am working on a project where we using technologies like Java, velocity etc. I am working on a task where I display data by means of a HTML table having 5 columns with 1st column being checkbox selection. I need some help with this - "If the user is going to select checkboxes on 1,3,5 rows then I need to move those selected rows on the top of this table." I am getting a Java Object and looping thru that Java Object in the velocity file using For Loop to display the data in this HTML table. someone advised me using Java comparator I can do this but I dont have much idea about it. Can someone please provide me code for how to do this. I very much appreciate your help.
Thanks
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38041
    
  22
Welcome to the Ranch

I am not sure you need a Comparator; all you need to do is get your Row object to return whether your box is selected, maybe with a public boolean checkboxIsSelected() method. Then you can sort on whether the boxes are selected. Consider true as greater than false in your sort method. If you are using a Comparator, that is what you would have to compare: whether you have false-true (return -1) or true-false (return 1) or the two the same (return 0). You can find the details of Comparator here.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: sorting selected checkboxes to the top of table
 
Similar Threads
Checkbox Issue
JSP creating html rows for displaying data
Maintain table checkboxes state after sorting
A diffrent type of checkbox problem
I'm stumped!