This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help with sorting

 
jay lai
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using JSTL and Hibernate to get data. Now i need to sort the columns that display on the jsp such as click of "ID" columsn , it will sort by asc or desc, so on and so forth.
please help me with any hints or clues.
Many thanks in advance

Sample of the the jsp display



[ March 01, 2007: Message edited by: Bear Bibeault ]
[ March 01, 2007: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65116
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Pls" is not a word. Please use real words such as "Please" when posting to the forums. Please read this for more information.

Also, as this has nothing to do with apllication frameworks, it has been moved to the JSP forum.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65116
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As with all other large problems, start one step at a time.

I assume that you want to sort upon a click of the column header, right?

Start there. How would you display an alert when the user clicks on the header?
 
jay lai
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There won't be any alert, just like normal sorting , display as **a link** <a href> to the header, and if you click the links it will sort the column
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65116
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, my point with the alert is that it's the first step to checking that your code reacts to the mouse click. It would be replaced with real code once you get to that point.

Again, one step at a time. Let me know when you've got the column header rigged up to react to a mouse click.
 
Naveen Kumar
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jai,

Below Link Will Help To you.

http://www.mingyi.org/other/ts_demo.html

Regards
Kumar
 
jay lai
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kumar:
Thanks, I am going to take a look and let see if I can use for my stuff.
Regards
 
Karthik Srikanti
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jay,

You can use the link given by Kumar if your data has no pagination. But if you need pagination, or if you dont want to use javascript, you can use display tags. You can seamlessly fit into your application and pass it an object in any scope in the page. You can configure sorting. You can get them at this link

http://displaytag.sourceforge.net/11/

Cheers
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of doing this in Java, you could also handle this in JavaScript on the client (if you can require JS). Have a look at the table at the bottom of this page. This technique also knows how to sort text, numbers and dates differently. It slows down for really large tables, though. Feel free to steal the JS
 
jay lai
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
thanks for the hints, I tried to plug in the javascript that Kumar has refered to , it works fine, the only problem i have is, I added a column with checkbox into the table, so if the user **select check box ** and then do ** sort **, if I right click and view source from the browser, the order of the record is not match with the checkbox.
Meaning, the sorting on client site only, so the order of records first time load the page, stay the same, so you could select checkbox with value=25, but behind the scence it is still checkbox with value=1.
Sample:


So any better way to resolved this problem, Again thanks in advance
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic