By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,600 Members | 1,887 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,600 IT Pros & Developers. It's quick & easy.

Script to sort tables

P: n/a
I maintain a site that basically consists of a few hundred HTML tables
with sales data. I need to add custom sorting to such tables: clicking
on a table header should sort the table by that column.

I think client-side JavaScript is the most feasible solution. Can you
recommend me a pre-written script for this task? Requirements are:

* I don’t expect it to work in tables with groups (which involve title
rows, rowspans and subtotals) but it should at least consider a basic
layout: header, data and footer

* Data is formatted in Spanish and often has extra chars at the end
(e.g. "1.000,25 EUR") so I guess the script should allow custom compare
functions

* Performance must be acceptable in "large" tables (let's say, a dozen
columns along 500 rows)

Thank you in advance for any suggestion,
P.S. Yep, I'm already googling ;-)
--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--
Jul 21 '08 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Álvaro G. Vicario escribió:
I maintain a site that basically consists of a few hundred HTML tables
with sales data. I need to add custom sorting to such tables: clicking
on a table header should sort the table by that column.
[...]
P.S. Yep, I'm already googling ;-)
Sorry, I hit "Send" by mistake; I was saying that I'm already googling
but I've found so many scripts that I'm kinda lost.

--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--
Jul 21 '08 #2

P: n/a
On Jul 21, 1:57*pm, "Álvaro G. Vicario"
<alvaroNOSPAMTHA...@demogracia.comwrote:
I maintain a site that basically consists of a few hundred HTML tables
with sales data. I need to add custom sorting to such tables: clicking
on a table header should sort the table by that column.

I think client-side JavaScript is the most feasible solution. Can you
recommend me a pre-written script for this task? Requirements are:

* I don’t expect it to work in tables with groups (which involve title
rows, rowspans and subtotals) but it should at least consider a basic
layout: header, data and footer

* Data is formatted in Spanish and often has extra chars at the end
(e.g. "1.000,25 EUR") so I guess the script should allow custom compare
functions

* Performance must be acceptable in "large" tables (let's say, a dozen
columns along 500 rows)

Thank you in advance for any suggestion,
Alvaro,

Primer intento : http://tinyurl.com/55rtpf

Va bien en Safari, Opera, IE, pero hace algo raro con la tabla en
FireFox.

Basta con hacer click en una columna para ordenar por esa columna.
Otro click invierte el orden.
Hay que revisar algunas cosas, pero es un principio.

--Jorge.
Jul 21 '08 #3

P: n/a
Jorge wrote:
On Jul 21, 1:57 pm, "Álvaro G. Vicario"
<alvaroNOSPAMTHA...@demogracia.comwrote:
>I maintain a site that basically consists of a few hundred HTML tables
with sales data. I need to add custom sorting to such tables: clicking
on a table header should sort the table by that column.

I think client-side JavaScript is the most feasible solution. Can you
recommend me a pre-written script for this task? Requirements are:

* I don’t expect it to work in tables with groups (which involve title
rows, rowspans and subtotals) but it should at least consider a basic
layout: header, data and footer

* Data is formatted in Spanish and often has extra chars at the end
(e.g. "1.000,25 EUR") so I guess the script should allow custom compare
functions

* Performance must be acceptable in "large" tables (let's say, a dozen
columns along 500 rows)

Thank you in advance for any suggestion,

Alvaro,

Primer intento : http://tinyurl.com/55rtpf

Va bien en Safari, Opera, IE, pero hace algo raro con la tabla en
FireFox.

Basta con hacer click en una columna para ordenar por esa columna.
Otro click invierte el orden.
Hay que revisar algunas cosas, pero es un principio.

--Jorge.
http://www.kryogenix.org/code/browser/sorttable/
Jul 21 '08 #4

P: n/a
In comp.lang.javascript message <3b6f8f4a-4071-4b63-a596-8181096c6f91@y3
8g2000hsy.googlegroups.com>, Mon, 21 Jul 2008 12:24:41, Jorge
<jo***@jorgechamorro.composted:
>
Primer intento : http://tinyurl.com/55rtpf
IE7 - Error: 'parentNode' is null or not an object

--
(c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/- FAQish topics, acronyms, & links.
Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
Do not Mail News to me. Before a reply, quote with ">" or "" (SonOfRFC1036)
Jul 22 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.