jQuery tablesorter:修改其对空单元格进行排序的方式 [英] JQuery tablesorter: Modify how it sorts empty cells

查看:89
本文介绍了jQuery tablesorter:修改其对空单元格进行排序的方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张大桌子,想使用tablesorter进行排序.我要处理的问题是,在对数字进行排序时,tablesorter充当空单元格的0.如何将空白单元格推到底部?

I have a big table and want to sort using tablesorter. The problem I'm dealing with is that tablesorter act as 0 for empty cells when sorting with numbers. How can I push the empty cells to bottom?

例如,表排序器就是这样

As an example, tablesorter sorts like that

-5
-4
-1
<empty cell>
<empty cell>
6
7
15
23

我想排序为

-5
-4
-1
6
7
15
23
<empty cell>
<empty cell>

推荐答案

您可以指定自己的文本提取功能:

You can specify your own text extraction function:

 $(table).tablesorter({          
    textExtraction: function (node)              
        { 
            if (node.innerHTML.length == 0)
            {
                return "999999999";  // or some suitably large number!
            }
            else
            {
                return node.innerHTML;
            }           
        }       
} ); 

这篇关于jQuery tablesorter:修改其对空单元格进行排序的方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆