I haven't got a fix, but I have more information.

The example on tablesorter.com that uses colspans works, but it is
using an old 2.0 version of tablesorter. The example on
tablesorter.com doesn't work on 2.0.3.

The suggested change below doesn't work with multiple rows of THs.


On May 4, 6:47 pm, Amos Robinson <amos.robin...@gmail.com> wrote:
> Hi all,
>
> I sent an email to the jquery-plugins list before noticing that it
> seems to be defunct. I'll quickly try to recreate from memory here...
>
> I tried to get tablesorter to sort a table looking something like this:
> <table>
> <thead>
>         <th>One</th>
>         <th colspan="2">Two</th>
>         <th>Four</th>
> </thead>
> <tbody>
> <tr>
>         <td>1</td>
>         <td>2</td>
>         <td>3</td>
>         <td>4</td>
> </tr>
> ...etc...
> </tbody>
> </table>
>
> But if I try to sort by 'Four', it will sort by the third column instead.
> So, here is a simple, naiive bugfix that seems to work for me; I'd
> like to hear any feedback that anyone has. I haven't tried at all with
> colspans in the data.
>
> Thanks,
> Amos Robinson
>
> --- /Users/amosrobinson/Desktop/jquery.tablesorter.js   2009-05-04
> 14:46:36.000000000 +1000
> +++ jquery.tablesorter.js       2009-05-04 15:03:26.000000000 +1000
> @@ -297,10 +297,14 @@
>
>                                 $tableHeaders = $("thead th",table);
>
> +                               var colspan_count = 0;
> +
>                                 $tableHeaders.each(function(index) {
>
>                                         this.count = 0;
> -                                       this.column = index;
> +                                       this.column = colspan_count;
> +                                       colspan_count += this.colSpan || 1;
> +
>                                         this.order = 
> formatSortingOrder(table.config.sortInitialOrder);
>
>                                         if(checkHeaderMetadata(this) || 
> checkHeaderOptions(table,index))
> this.sortDisabled = true;

Reply via email to