473,326 Members | 2,655 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Script to sort tables

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
4 1072
Á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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Djakobsson | last post by:
Hi, I have a SQL server DB for a document handeling system. For the new version of the system the database have been updated with some new tables, new stored procedures and updated stored...
5
by: Neil | last post by:
How can I create a script that updates a table with new fields without losing the data in the table (i.e., without dropping and recreating the table)? Thanks.
5
by: Bill Reid | last post by:
Hello, I am a just-beyond-beginning user of Access 97 on a Windows 98se machine (a single, non-networked home machine). All of a sudden I am unable to sort any of my tables. I click on any...
7
by: DC Gringo | last post by:
I have a datagrid that won't sort. The event handler is firing and return label text, just not the sort. Here's my Sub Page_Load and Sub DataGrid1_SortCommand: -------------------- Private...
2
by: shuckjunkmail | last post by:
It was suggested that I re-submit this question as a new post rather than adding onto an old and unanswered post. The basic problem has to do with the .NET datagrid and sorting. I am having...
3
by: Peter Proost | last post by:
Hi group, I've got this, a dataset which contains ds.tables(0).rows(0).item(0) = "HO" ds.tables(0).rows(1).item(0) = "L1" ds.tables(0).rows(2).item(0) = "L2" ds.tables(0).rows(3).item(0) =...
2
by: azmiza | last post by:
Hi friend, I am new in this area. Hope members can help me on my script below. I want to create Previous and Next button but it runs until maximum execution time. Help me <?php #script...
1
by: jenson | last post by:
<?php /* * Created on Apr 13, 2007 * * To change the template for this generated file go to * Window - Preferences - PHPeclipse - PHP - Code Templates */ require_once 'init.php'; ...
3
by: aRTx | last post by:
I have try a couple of time but does not work for me My files everytime are sortet by NAME. I want to Sort my files by Date-desc. Can anyone help me to do it? The Script <? /* ORIGJINALI
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.