How to sort data when clicking on a column header?
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Kady_Ny
Posted On:   Tuesday, November 13, 2001 12:52 PM

The data got back from the ResultSet will be displayed in a table with the first row being the column header. The table will look like this: Name | Address | Phone | C | 1234....|713000| A | 2356....|5010000| etc. When I click on the Name column, I want the data sorted by the name in an ascending order. In this case, the result would be A | 2356 |5010000| C | 1234|7130000| When I click on the column Name again, I want it sorted in descending order. In this case, the result will look like: C | 1234....|713000| A | 2356....|5010000| I want the same thing happen when I click on any oth   More>>

The data got back from the ResultSet will be displayed in a table with the first row being the column header.

The table will look like this:


Name | Address | Phone |


C | 1234....|713000|


A | 2356....|5010000|


etc.


When I click on the Name column, I want the data sorted by the name in an ascending order. In this case, the result would be


A | 2356 |5010000|


C | 1234|7130000|


When I click on the column Name again, I want it sorted in descending order. In this case, the result will look like:


C | 1234....|713000|


A | 2356....|5010000|


I want the same thing happen when I click on any other column.

How can I do this?

Is using List achieve my objectives? If so, how do I store my data retrieved from the ResultSet into List?

   <<Less

Re: How to sort data when clicking on a column header?

Posted By:   brett_haas  
Posted On:   Tuesday, November 13, 2001 01:14 PM

Here is some of the javascript I was referring too...




Re: How to sort data when clicking on a column header?

Posted By:   brett_haas  
Posted On:   Tuesday, November 13, 2001 01:04 PM

Use javascript. When they click on a heading, let it bring up a confirm() dialog window, and have the ok button be
ASC and cancel button be DESC, then just pass which ever value they choose to the page to re-sort the display on the server.


OR


you can have all columns have the value of ASC to begin with, once they click on a column header, the display will re-sort ASC by the column header, and that column header's value will change to DESC now.

About | Sitemap | Contact