Exclude a column from being sorted using jQuery tablesorter

Chad Birch picture Chad Birch · Jan 12, 2009 · Viewed 16.8k times · Source

I am looking for a way to exclude a single column from being sorted using jQuery's tablesorter plugin. Specifically, I have a fairly large table and would like to keep a "row number" column fixed so that it is easy to see what position in the table a particular row is, after sorting.

For example:

#    name
-----------
1    papaya
2    apple
3    strawberry
4    banana

When sorted on the name column, should result in:

#    name
-----------
1    apple
2    banana
3    papaya
4    strawberry

Thanks.

Answer

bcoughlan picture bcoughlan · Oct 17, 2012

For those who find this while looking for a way to exclude a column from being sortable (i.e. clickable header on the column), the below example excludes column 4 (zero-indexed) from being sorted):

$("table").tablesorter({
    headers: {4: {sorter: false}}
});