0

我在货币选项卡中的数据表排序有问题。当我尝试对货币/价格列进行排序时..

前任

A - $ 10,0000
B - $ 4,000
C - $ 8,000

在 Chrome 中:

它工作正常,它显示正确的答案。这是BCA升序。

在 Mozilla 和 IE 中:

它不显示正确的答案,而是ACB按升序显示此答案。我相信它读取自 moz 以来的第二低数字,并且 iE 将 $ 符号读取为字符串的一部分。

有什么解决办法吗?

你可以试试这个我发现的 示例链接在 Chrome 和 Mozilla 中打开它

4

1 回答 1

0

我只是解决我的问题。

而不是为导致错误的货币插件创建扩展的 .js 文件。我在创建数据表对象的同时编写代码。像这样的东西:

            $(document).ready(function(){
            model_select();
            $('.data_table').dataTable({
                "bJQueryUI": true,
                "sPaginationType": "full_numbers",
                "bRetrieve":true,
                "aoColumnDefs": [
                  { "sType": "currency", "aTargets": [ 10 ] }
                ]
            }); 
            // Change this list to the valid characters you want
            var validChars = "$£€c0123456789-,";

            // Init the regex just once for speed - it is "closure locked"
            var str = jQuery.fn.dataTableExt.oApi._fnEscapeRegex("$£€c0123456789-,");
            var re = new RegExp('[^'+str+']');


            jQuery.fn.dataTableExt.aTypes.unshift(
               function ( data )
                {
                    if ( typeof data !== 'string' || re.test(data) ) {
                        return null;
                    }

                    return 'currency';
                }
            );              
        });
于 2013-05-08T04:25:36.953 回答