【问题标题】:Datables numeric sorting issue数据表数字排序问题
【发布时间】:2012-02-07 08:34:42
【问题描述】:

使用 jQuery 数据表 1.9.0

$('#list').dataTable( {       
    "bJQueryUI": true, 
    "iDisplayLength": 25,
    "aaSorting": [[ 0, "desc" ]]       
} )

当我尝试按 id 排序时出现此屏幕

我该如何解决这个问题?

【问题讨论】:

    标签: javascript jquery sorting datatables


    【解决方案1】:

    尝试设置data type of particular column:

    $(document).ready(function() {
        $('#example').dataTable( {
            "aoColumns": [
                { "sType": "numeric-comma" },
                null,
                null,
                null,
                null
            ]
        } );
    } );
    

    【讨论】:

    • 让我走上了正轨,但发现该链接背后的代码很奇怪。为什么要用小数点代替逗号?
    【解决方案2】:

    试试natural-desc

    $('#list').dataTable( {       
        "bJQueryUI": true, 
        "iDisplayLength": 25,
        "aaSorting": [[ 0, "natural-desc" ]],
        "aoColumns": [
            { "sType": "natural-desc" },
            ....
        ]
    } )
    

    参见:Natural sorting 来自Plugin List

    【讨论】:

    • 是的,但是当我点击 ID 列时,它会重新排序整列,结果相同
    猜你喜欢
    • 1970-01-01
    • 2020-11-17
    • 2019-10-21
    • 2017-11-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多