Google Answers Logo
View Question
 
Q: Javascript Table Sorting with Alternate Row Highlighting ( Answered 5 out of 5 stars,   4 Comments )
Question  
Subject: Javascript Table Sorting with Alternate Row Highlighting
Category: Computers > Programming
Asked by: trevorturk-ga
List Price: $50.00
Posted: 22 May 2005 16:34 PDT
Expires: 21 Jun 2005 16:34 PDT
Question ID: 524440
In addition to the fix in this answer...

http://answers.google.com/answers/threadview?id=524043

I would like to have alternate row highlighting built into the script.
Alternate rows should have a css class name of "alternaterow", and the
highlighting should still appear properly after resorting.

The original script can be found here:

http://www.kryogenix.org/code/browser/sorttable/

I would like the "fixed" sorttable.js to enable this alternate row
highlighting without my having to do anything but include the script
as the original example shows. Also, this script should contain the
fixes from the last "answer".
Answer  
Subject: Re: Javascript Table Sorting with Alternate Row Highlighting
Answered By: wildeeo-ga on 23 May 2005 11:47 PDT
Rated:5 out of 5 stars
 
Hi, trevorturk.

I've made the modification to the script you requested. Now, when the
page loads or when a user re-sorts the rows, every other line will
have a css class of 'alternaterow' applied to it. The other
(non-title) rows will have the class 'tablerow' applied to them but,
of course, you don't have to define that.

You can change the styles of the rows by defining the CSS styles
tr.alternaterow (or .alternaterow), and tr.tablerow (or .tablerow).
Other than that, you shouldn't need to make any changes.

There's an example at
http://work.hexx.net/ga/highlightedsorttable/example.html (sorry for
the hideous colour scheme :-)), with the modified script file
available from http://work.hexx.net/ga/highlightedsorttable/sorttable.js.

As with the previous modifications, it seems to work fine with Safari
2, Firefox 1.0.4 and Internet Explorer 6.

If you have any questions or problems with this, please request a clarification.

--wildeeo
trevorturk-ga rated this answer:5 out of 5 stars
This is exactly what I needed, and very fast (again). I really
appreciate the help - you saved me a ton of time.

Comments  
Subject: Re: Javascript Table Sorting with Alternate Row Highlighting
From: pcmac-ga on 12 Jul 2005 14:44 PDT
 
Just want to give a huge "thanks" as I was looking for exactly the same thing.
Subject: Re: Javascript Table Sorting with Alternate Row Highlighting
From: morland-ga on 14 Sep 2005 13:17 PDT
 
Those example and javascript links appear to be dead.
Subject: Re: Javascript Table Sorting with Alternate Row Highlighting
From: trevorturk-ga on 19 Sep 2005 10:08 PDT
 
I posted the script here:

http://www.almosteffortless.com/files/sorttable.js

I made some changes that are noted there - like removing the arrows,
and changing the CSS classes to "tablelist" and "tablelist-alt". Let
me know if you have questions.
Subject: Re: Javascript Table Sorting with Alternate Row Highlighting
From: nemozob-ga on 20 Dec 2005 16:29 PST
 
Any idea on how to sort images? I would have thought it would sort
them alphabetically but it doesn't seem to work. I think it's just a
matter of adding a new function that can parse the img tag.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy