Sorting a HTML table with Javascript

G

Gareth Gale

I'm trying to implement a way of allowing a user to sort a HTML table
via Javascript on the client. I've seen lots of samples where single
column sorting (asc or desc) is shown, but I'd like nested sorting i.e.
sort by col1 asc, then by col2 desc etc. Can anyone help ?
 
M

McKirahan

Gareth Gale said:
I'm trying to implement a way of allowing a user to sort a HTML table
via Javascript on the client. I've seen lots of samples where single
column sorting (asc or desc) is shown, but I'd like nested sorting i.e.
sort by col1 asc, then by col2 desc etc. Can anyone help ?

Next time first try a Google search on:

Sorting a HTML table with Javascript
 
G

Gareth Gale

As per my initial message, I have done this. The post refers to the fact
that there seems to be plenty of examples where single column sorting is
permitted, but not nested sorting. I'd really like examples of the latter.
 
M

mark4asp

As per my initial message, I have done this. The post refers to the fact
that there seems to be plenty of examples where single column sorting is
permitted, but not nested sorting. I'd really like examples of the latter.

In theory, can't you put the groups in TBODYs, sort by TBODY and then
by TD within the TBODY?

But how many different ways is the table to be sorted?

Apart from using TBODY method, is it possible to add attributes to a
TD for each particular sort group and then sort by these user created
attributes?
 
M

McKirahan

Gareth Gale said:
As per my initial message, I have done this. The post refers to the fact
that there seems to be plenty of examples where single column sorting is
permitted, but not nested sorting. I'd really like examples of the latter.

Sorry, I did not read your post as well as I should have.

You should be able to adopt single column sorting logic for multiple
columns.

The trick is to allow the user to identify what columns sort in what
sequence and how (asc or desc). Are you looking for a generic solution or
do you have a specific table in miond? If the latter, what are the columns
and what sort options do you want?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top