Does your site run on Perch CMS? Hire me to help. Perch CMS Development

JavaScript table sorting

Posted on by Clive Walker in Web Development JavaScript

I wrote this post a while back. The content can still be relevant but the information I've linked to may not be available.

I know we are not building websites using tables for layout any more (ahem) but tables are still the best way of displaying related data. The table often pulls information from a database using an SQL query that orders the data according to one of the column data headers. For example, display some data and sort it alphabetically or perhaps in date order, either descending or ascending.

Here's a great table sorting script by Stuart Langridge that gives your website users1 the ability to click on each column header to sort the data themselves. Implementation is easy, download the script, reference it in the head of your document, add a class name to your table, and that's it. Table sorting made easy....

I have used this to make the admin section of one of my own websites much easier to manage. The table sorting script provides alternative table views without resorting to additional database calls. Cool.

1 Best practice: When using JavaScript, it is important that the script should degrade gracefully. That is, web visitors who have disabled JavaScript will still see be able to use the website and view the data. The functionality will not be there but the website still works. In this case, the data is still viewable with JavaScript turned off.

Technorati :

Does your site run on Perch CMS? Hire me to help. Perch CMS Development


Comments are OFF for this post.

© 2024 Clive Walker