【问题标题】:Descending sort in jquery data table does not work properlyjquery数据表中的降序排序不能正常工作
【发布时间】:2016-09-11 08:26:04
【问题描述】:

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

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

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

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

我该如何解决这个问题?

【问题讨论】:

    标签: jquery datatables columnsorting


    【解决方案1】:

    你试过了吗,

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

    如果您使用带数字的 html,您应该尝试 html-num

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

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

    如果您使用的是旧版本的数据表(即版本 formatted-numbers.js 并尝试上述代码。更多关于DataTable sorting

    【讨论】:

    • 我正在使用 jquery.dataTables.min.js 版本 1.10.11。还是不行!
    猜你喜欢
    • 2022-01-14
    • 1970-01-01
    • 2013-09-26
    • 2016-07-06
    • 1970-01-01
    • 1970-01-01
    • 2013-12-14
    • 2017-02-12
    • 1970-01-01
    相关资源
    最近更新 更多