• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to Sort Table Fields

 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi To All,

I am having a table as follows

TestCaseName CretedDate CreatedBy
---------------------------------------
test1 12/24/2007 Author1
cz_100 11/20/2006 Author2
an_10 10/08/2007 Author3

If i click on TestCaseName rows should be sort by TestCaseName in Ascending order.
If i click on TestCaseName second time rows should be sort by TestCaseName in Descending Order.(Same Procedure for CreatedDate also)

This table Values are stored in Map.

Any one please give me source code.
Thaks in advance.
 
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you're using a JTable, check out javax.swing.table.TableRowSorter (available since Java 6).
 
sirisha makkapati
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My table is created by using HTML tags
 
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Sirisha,
You can do this using Javascript.
This will be a useful link
Javascript HTML Table sort

Hope this helps
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please take the time to choose the correct forum for your posts. This forum is for questions on Advanced Java.

This post has been moved to a more appropriate forum.
 
sirisha makkapati
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sivaraman,

First of all i wanted to wish you,Wish you happy and prosperous new year.

Second thing:i.e
The code you had given for Html Table Sort in previous that is working quite good.
Thank you very much for that.

Now i am getting a small issue regarding this,I am spliting table into two parts and displaying data(to reduce the table length) .

After sorting,The second part first Row is diplaying as empty row(if the row number is odd).
If even number of rows are there means data is displaying properly.
Like as follows.

NameCre_dateCre_byNameCre_dateCre_by
------------------------------------------------------------------


a12-04-07siri
b11-05-07authc12-09-07admin

can you give any idea regarding this.
 
reply
    Bookmark Topic Watch Topic
  • New Topic