This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sorting selected checkboxes to the top of table

 
arjun Pal reddy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48649
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic