jquery 数据 table 中的降序排序无法正常工作

Descending sort in jquery data table does not work properly

我使用 jQuery 数据 table 创建了一个 table。在特定列中,我有一个从 32 到 1000 的数值范围(没有字符串值)。

对于本专栏,我使用了以下选项:

{ title: "Approx.count" ,"sType": "numeric"},

从 32 开始升序排序正常,但降序排序不起作用(它从 99 而不是 1000 开始)。

我该如何解决这个问题?

你试过了吗,

{ title: "Approx.count" ,"sType": "num"},

或者如果您使用 html 和数字,您应该尝试 html-num

如果您使用的是数据table 1.10+ 版,请使用以下代码使用内置代码对数字进行排序,

$('#example').dataTable( {
    columnDefs: [
       { type: 'formatted-num', targets: 0 }
    ]
 });

如果您使用的是旧版本的数据 table(即版本 < 1.10),则包括 formatted-numbers.js and try the above code. More on DataTable sorting