Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 数据表货币排序_Jquery_Regex_Sorting_Datatables - Fatal编程技术网

Jquery 数据表货币排序

Jquery 数据表货币排序,jquery,regex,sorting,datatables,Jquery,Regex,Sorting,Datatables,我的问题是关于我的特定货币类型的排序 我有以下类型的货币: 这是我整个数据库表中的第五行 我需要能够对数据表的价格进行排序,我被告知这将起作用: jQuery.extend(jQuery.fn.dataTableExt.oSort, { "currency-pre": function (a) { a = (a === "-") ? 0 : a.replace(/[^\d\-]/g, ""); return parseFloat(a); },

我的问题是关于我的特定货币类型的排序
我有以下类型的货币:

这是我整个数据库表中的第五行

我需要能够对数据表的价格进行排序,我被告知这将起作用:

jQuery.extend(jQuery.fn.dataTableExt.oSort, {
    "currency-pre": function (a) {
        a = (a === "-") ? 0 : a.replace(/[^\d\-]/g, "");
        return parseFloat(a);
    },
    "currency-asc": function (a, b) {
        return a - b;
    },
    "currency-desc": function (a, b) {
        return b - a;
    }
});
然而,这在我的情况下不起作用

对于数据表初始化,我有两种可能的结果:

$('table').dataTable( {
        "aoColumns": [{"sType": "currency"}],
        "order": [[ 0, "desc" ]],
        "columnDefs": [
            { "type": "de_datetime", targets: 0 },
            { "orderable": false, "targets": 2 },
            { "type": "currency", targets: 5 }
        ],
        stateSave: true
    } );
而且

 $('table').DataTable( {
    "ajax": "<?php echo SCRIPT_URL; ?>api/admin_overview_quotations_json.php",
    "columns": [
        { "data": "post_time" },
        { "data": "number" },
        { "data": "company" },
        { "data": "reference" },
        { "data": "total_price" },
        { "data": "status" },
        { "data": "sales_call_date" },
        { "data": "quotation_id" }
    ],
    "order": [[ 0, "desc" ]],
        "columnDefs": [
            { "type": "de_datetime", targets: 0 },
            { "type": "de_datetime", targets: 6 },
            { "orderable": false, "targets": 1 },
            { "render": function ( data, type, row ) {
                return '<a type="button" class="btn btn-primary view_by_id hidden-xs hidden-md" href="#" data-toggle="modal" data-target="#view" data-url=<?php echo SCRIPT_URL; ?>api/admin_download_quotation.php?quotation_id=' + data + '&action=view" data-tooltip="tooltip" data-placement="top" title="<?php echo ASLang::get('View offer'); ?>"><span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span></a> <a type="button" class="btn btn-primary" href="<?php echo SCRIPT_URL; ?>admin/new-project.php?type=offer&id=' + data + '&action=manage" data-tooltip="tooltip" data-placement="top" title="<?php echo ASLang::get('Edit offer'); ?>"><span class="glyphicon glyphicon-edit" aria-hidden="true"></span></a> <a type="button" class="btn btn-primary" href="<?php echo SCRIPT_URL; ?>admin/new-project.php?type=offer&id=' + data + '&action=order" data-tooltip="tooltip" data-placement="top" title="<?php echo ASLang::get('Make order from offer'); ?>"><i class="icon-basket"></i></a> <a type="button" class="btn btn-primary hidden-xs hidden-md" href="<?php echo SCRIPT_URL; ?>api/admin_download_quotation.php?quotation_id=' + data + '&action=download" data-tooltip="tooltip" data-placement="top" title="<?php echo ASLang::get('Download quotation'); ?>"><span class="glyphicon glyphicon-download-alt" aria-hidden="true"></span></a> <a type="button" class="btn btn-primary visible-xs visible-md" href="<?php echo SCRIPT_URL; ?>api/admin_download_quotation.php?quotation_id=' + data + '&action=view" target="_blank" data-tooltip="tooltip" data-placement="top" title="<?php echo ASLang::get('View offer'); ?>"><span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span></a>';
                },
                "targets": 7
            }
        ],
        stateSave: true,
    "language": {
        "url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Dutch.json"
    }
} );

但这也没用。

你说它不起作用是什么意思?它没有排序?按字母顺序排序?它显示了一条错误消息?m.nachury很抱歉没有说清楚,它没有以任何方式对货币进行正确排序。您找到解决方案了吗?我现在也在努力解决同样的问题,@Yoshi我一直无法解决。你说它不起作用是什么意思?它没有排序?按字母顺序排序?它显示了一条错误消息?m.nachury很抱歉没有说清楚,它没有以任何方式对货币进行正确排序。您找到解决方案了吗?我目前正在努力解决同样的问题,@Yoshi我一直无法解决。
(/[^\d\-]/g
[^\d\-]