jQuery tablesorter plugin secondary “hidden” sorting

后端 未结 6 1829
粉色の甜心
粉色の甜心 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 07:02

    You need to write your own parser. Your parser might end up looking something like:

    var months = {'January':1,'February':2, ...};
    $.tablesorter.addParser({
        id: 'myDate', 
        is: function(s) { return false; }, 
        format: function(s) {
            var x = s.split(', ');
            return x[1]+'-'+months[x[2]];
        },
        type: 'numeric' 
    });
    

    Not tested, but general idea.

提交回复
热议问题