Search code examples
jquerytablesorter

jQuery tablesorter - Get sort direction in custom parser


Is there a way with the tablesorter jQuery plugin to get the sort direction in a custom parser? I want to do different things with the sorting depending on the direction.

$.tablesorter.addParser({
    id: 'rawText', 
    is: function(s) {
        return false; 
    }, 
    format: function(s) {

        // How can I get sort direction in here?

        return s.toLowerCase().replace(/(<([^>]+)>)/ig, '');
    },
    type: 'text' 
});

Solution

  • The main issue is that parsers are only used to extract data on initialization and during an update. What you'll need to do is add code to the textExtraction & textSorter options.

    I think you might be looking for the answer posted

    • Here - Change sort values depending on sort direction.
    • Or here - Dynamically sort one column in two different ways.