jQuery tablesorter plugin secondary “hidden” sorting

后端 未结 6 1804
粉色の甜心
粉色の甜心 2021-02-05 06:24

I\'m using the jQuery tablesorter plugin and I have a column that contains name of month and year like this

April, 1975
January, 2001

I would l

6条回答
  •  北荒
    北荒 (楼主)
    2021-02-05 06:46

    Just using the textExtraction function. Set data-sort-value on your TDs. Defaults to normal text if it's not present.

    $(".sort-table").tablesorter({
        textExtraction: function(node) {
            var attr = $(node).attr('data-sort-value');
            if (typeof attr !== 'undefined' && attr !== false) {
                return attr;
            }
            return $(node).text(); 
        } 
    }); 
    

提交回复
热议问题