Easy Sort Html Table / Grid View using JQuery example
1st u need the gloruis sortElements by James Padolsey (well after getting JQ) http://james.padolsey.com/javascript/sorting-elements-with-jquery/ now grid views gives us a row with TH and the rest r TD so we need: 1 - take all the TRs 2 - build the compare callback func 3 - make it skip the TH 4 - be able to sort desc so here, i put this just after James's code: function MakeTableSortable(tableID) { $( "#" + tableID + " th" ).click( function () { var index = this .cellIndex; if ( this .abc == null ) { this .abc = true ; } else { this .abc = ! this .abc; } $( "#" + tableID + " tr" ).sortElements( function (a, b) { if (a.cells[0].tagName == "TH" || b.cells[0].tagName == "TH" ) { return 0; } var _a = a.cells[index].innerText.toLowerCase(); var _b = b.cells[index].innerText.toLowerCa