0

Web サイトにデータテーブルがあり、1,999,999,999 で数値を並べ替えようとしましたが、うまくいきません。Google で多くのヒントを参考にして問題を解決しようとしましたが、役に立ちませんでした。

それは私のテーブルのJavaScriptコードです

$('.d3uitems').dataTable({
        "bJQueryUI": true,
        "sPaginationType": "full_numbers",
        "sDom": '<""l>t<"F"p>',
        'aaSorting': [[ 0, 'desc' ]]
    }).columnFilter({
            aoColumns: [ null,
                     { type: "text"},
                         null,
                     null,
                     { type: "text"},
                     null
                ]
    });

これは、数字を並べ替えようとするデータテーブルです。

http://www.lootfinder.net/index.php?page=d3items

4

1 に答える 1

1

試すことができます。DataTable の並べ替え関数を上書きし、"," を置き換えます。

    <script type="text/javascript" charset="utf-8">

        jQuery.fn.dataTableExt.oSort['numeric-comma-asc']  = function(a,b) {
            var x = (a == "-") ? 0 : a.replace( /,/g,"" );
            var y = (b == "-") ? 0 : b.replace( /,/g,"" );
            alert( "x=" + x );
            x = parseFloat( x );
            y = parseFloat( y );
            return ((x < y) ? -1 : ((x > y) ?  1 : 0));
        };

        jQuery.fn.dataTableExt.oSort['numeric-comma-desc'] = function(a,b) {
            var x = (a == "-") ? 0 : a.replace( ",","" );
            var y = (b == "-") ? 0 : b.replace( ",","" );
            x = parseFloat( x );
            y = parseFloat( y );
            return ((x < y) ?  1 : ((x > y) ? -1 : 0));
        };


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

        } );
    </script>
于 2014-02-26T03:55:10.877 に答える