Question

I'm using jQuery Tablesorter to sort a table and everything works as expected. What I'd like to do is add a link above my table that says something along the lines of "Sort by Price" and when the user clicks the link I want the "Price" column to sort. Additionally, if they click it again, it would sort the price the other way. Is this possible?

Thanks! Manoj

Was it helpful?

Solution

From tablesorter.com

$(document).ready(function() { 
    $("table").tablesorter(); 
    $("#trigger-link").click(function() { 
        // 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; 
    }); 
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top