Jul
5
Simple Sortable Tables
Filed Under Computers & Tech, Software Development on July 5, 2007 at 6:51 pm
Despite the advent of broadband excessive round-trips to the server still slow websites down. Having to send a request to the server to get the same data again but in a different order each time someone wants to sort a table is just not efficient. Hence, what you want is some nice simple JavaScript to do it for you. Ideally this JavaScript should be cross-browser and should not require you to make any substantive changes to your mark-up. Well, the good news is that this ideal has been realized and has been released under the free and open source MIT License. I’m talking about Stuart Langridge’s Sorttable.
Assuming you use proper XHTML markup for your tables, in particluar thead
and tbody
tags, making your tables sortable is a two-step process:
- Include
sorttable.js
- Set the class of the tables you want sortable to
sortable
For a basic setup that’s it! If you want to get a little more fancy you can by doing things like making some columns un-sortable but that too is trivially easy. Honestly, I have no complaints at all about this script, it just works!
[tags]XHTML, tables, sortable tables, JavaScript[/tags]
Yeah, I used this one on a project a while back, does the job well.
Great I’ve been looking for something like this 🙂
This is exacly what I want. I use iWeb to develop my site. iWeb allows you to add HTML snippets but I don’t know how I would access the Head for a page in order to put a link to the Javascript there.
Do you have specific suggestions for iWeb users?
Thanks so much.
Love your site, by the way.
Hi Julie,
Thanks for your kind comments. I don’t have much experience with iWeb. I tried it once and hated it. Never went back. As you get more into web development the time will come when you want total control of your source. At that point you have out-grown iWeb. Maybe that time has come for you?
Sorry I can’t be or more help,
Bart.