Script to sort tables

Á

Álvaro G. Vicario

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 ;-)
 
Á

Álvaro G. Vicario

Á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.
 
J

Jorge

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.
 
D

Dr J R Stockton

In comp.lang.javascript message <[email protected]>, Mon,
21 Jul 2008 13:57:22, Álvaro G. Vicario <[email protected]
om> posted:
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.

Perhaps not. Consider storing the data in JavaScript (in simple arrays)
and sorting it there, using the HTML as a write-only display. For the
most efficient sort, the data should be pre-processed so that the
default sort method can be used.

<URL:http://www.merlyn.demon.co.uk/js-order.htm> may help.

It's a good idea to read the newsgroup c.l.j and its FAQ. See below.
 

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,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top