I thought I would share the following:

I inserted code (around line 64) to take into account when the THEAD
element doesn't exist.  This can happen (as in my case) when using a
GridView in .net.  The generated table contains the column headers as
the first row in the TBODY.  I essentially move this row into a new
THEAD prior to the execution of the rest of the TableSorter.  See the
code below:

    /** Remove the top row from the tbody and place in a thead if the
thead is missing. */
    for(var i=0,n=oTable.childNodes.length;i<n;i++){
        if(oTable.childNodes[i].nodeName=="THEAD"){
            break;
        }
        if(oTable.childNodes[i].nodeName=="TBODY"){
            var tBody = oTable.childNodes[i];
            var newThead = document.createElement("thead");
            oTable.insertBefore(newThead,tBody);
            newThead.appendChild(tBody.firstChild);
            break;
        }
    }

Reply via email to