The docs demo is using a different (ancient) versions of both jQuery and Tablesorter than you are. From comparing the sources I see that automatic col/row span detection is never done in the newer version. The spans detection function is still in there - but just not getting called. No idea why this regression has happened.
That being said, I can get your demo to run using this setup:
$(document).ready(function(){
$('#rowspan').tablesorter({
headers: {
4: {sorter: false},
5: {sorter: false},
6: {sorter: false},
7: {sorter: false}
}
});
});
Which if you know that the colspan>1
is a safe criteria to go by, then I would infer the header indexes like this:
$(function(){
var headers = {};
$('#rowspan thead th').each(function(i,h){
if (this.colSpan>1) { headers[i] = { sorter: false }; }
});
$('#rowspan').tablesorter({
headers: headers
});
});
Update:
A "working" example: http://jsbin.com/ucija3
The example looks like what you asked for or I don't understand your question. However, I have just discovered that clicking on headers labeled 3.1 - 4.2 throws exceptions. So, I guess my final answer to your question is: The current version of this plugin does not work with row or colspans.
Update:
A simple patch to make this work:
In the function buildHeaders
(line 290), change the line $tableHeaders = $("thead th",table);
to:
$tableHeaders = $("thead th:not([colspan]),thead th[colspan=1]",table);
A more complex an flexible patch:
Add a config parameter to buildHeaders
(line 290):
function buildHeaders(table, config) { # ...
And a filter to $tableHeaders
(line 299):
$tableHeaders = $("thead th",table).filter( config.headerFilter || '*' );
Pass the config to buildHeaders when it is called (line 504):
$headers = buildHeaders(this, config);
Add a filter when you initialize the tablesorter:
$(function(){
$('#rowspan').tablesorter({
headerFilter: function(){ return this.colSpan == 1; }
});
});
Here is a pre-patched version that includes the headerFilter
option and a demo of it in action.