Table Sorting with Javascript
May 25, 2007In past, I was asked by one of my colleague to implement table sorting in a website and provided with links on how to go about it. One of the reference that I used in my project was Standardista Table Sorting by Neil Cosby (cited, workingwith.me.uk). I found this as one of the easiest method to apply sorting in table without much effort. The following steps should guide you how
- First, download the Standardista Table Sorting module.
- Include the .js files in the HEAD of your webpage depending on file locations below:
<script type=’text/javascript’ src=’common.js’></script>
<script type=’text/javascript’ src=’css.js’></script>
<script type=’text/javascript’ src=’standardista-table-sorting.js’></script> - Make sure that the table you want to be sortable has a THEAD and a TBODY.
- Give the table that wants to be able to be sorted the class “sortable”.
- Load the page, and you’ll be able to sort the table by clicking on its headers!
Above steps you should be able to make your table in webpage dynamic with help of javascript, plus it is also compatible with some of popular the broswers around.
Posted by Vishal Reddy