pynovice
pynovice

Reputation: 7752

Disable tablesorter in one column in a table in jquery tablesorter?

I am using jquery-tablesorter like this:

$(document).ready(function() { 
    $("table").tablesorter(); 
        // set sorting column and direction, this will sort on the first and third column the column index starts at zero 
        var sorting = [[0,0],[2,0]];    
        // sort on the first column 
        $("table").trigger("sorton",[sorting]); 
        // return false to stop default link action 
        return false; 

});

There are total 5 columns in my table. How can I disable sorting in the last column?

Upvotes: 0

Views: 665

Answers (2)

12AX7
12AX7

Reputation: 310

I am using this and it works:

// Disable sorting in 5th column 
$("table thead th:eq(4)").data("sorter", false);

Upvotes: 0

stackErr
stackErr

Reputation: 4170

$(document).ready(function() { 
    $("table").tablesorter({
        headers:{
            4: { //last column
                   sorter: false;
            }
        }
    });
        // set sorting column and direction, this will sort on the first and third column the column index starts at zero 
        var sorting = [[0,0],[2,0]];    
        // sort on the first column 
        $("table").trigger("sorton",[sorting]); 
        // return false to stop default link action 
        return false; 

});

Upvotes: 2

Related Questions