logo Pascarello.com Integrating the Client with the Server
JavaScript Sortable Table

Well I dug down into my old JavaScript files and whipped this into a little better shape. It still could be improved, but that is for another day. I created this script becasue I was tired of seeing some really bad reasons for people using the serverside code to sort simple tables. This code just takes a couple of lines and does all of the hard work for you. This script allows you to pick the column type that you want to sort so your numbers, strings, and dates can be sorted correctly. I see alot of other implementations of this out there fail on this aspect. Enough with the chatting.

Below is a working example of the code in action!

cheap Miami Dolphins jerseys gucci outlet UK cheap authentic nfl jerseys Free shipping cheap Green Bay Packers jerseys cheap jerseys from china 2013 cheap Tampa Bay Buccaneers jerseys

Col 1 Col 2 Col 3 Col 3
1 A 1 1/13/1980
2 C 1.1 1/13/2005
3 D 1.11 1/13/1985
11 B 11. 1/13/2006
12 E 11.11 1/13/1989

There are a couple of files needed and are available in the zip file that you can download below.

The files included in the zip:

The basic code for the table above is:

var t1 = new sortableTable("t1",0,"int,str,float,date");
window.onload = function(){
  t1.init();
}
            

Now the syntax is var tableName = sortableTable(tableName, default index of column to be sorted, column types seperated with comma); I know that that can be improved, but it works for now. (please no hate mail!) I took the old script and added a quick bandaid!

Now since I coded it pretty badly, you need the table name to be the variable name, some oo would fix this, but I was lazy!

The possible sort types are int (integer), str (string), float (for floating point), and date (for um let me guess dates!).

Well I hope this gives you a start on sorting tables with the clientside. Take a look at the code since it manipulates nodes and a cutom sort. It is some fun stuff.

THE FILES

With all of this said, you can grab the files by downloading this zip file: The Zip


?005 Pascarello.com