Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/76.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
Javascript 基于单选按钮和复选框的数据表排序_Javascript_Jquery_Datatables - Fatal编程技术网

Javascript 基于单选按钮和复选框的数据表排序

Javascript 基于单选按钮和复选框的数据表排序,javascript,jquery,datatables,Javascript,Jquery,Datatables,我正在使用jQuery数据表。我在JSON中得到的数据表列值很少。在其中两列中,一列只有单选按钮,另一列只有复选框。我想根据复选框和单选按钮进行排序(比如,如果选中复选框,它应该首先出现)。我如何才能做到这一点?参见示例 /* Create an array with the values of all the checkboxes in a column */ $.fn.dataTable.ext.order['dom-checkbox'] = function ( settings, co

我正在使用jQuery数据表。我在JSON中得到的数据表列值很少。在其中两列中,一列只有单选按钮,另一列只有复选框。我想根据复选框和单选按钮进行排序(比如,如果选中复选框,它应该首先出现)。我如何才能做到这一点?

参见示例

/* Create an array with the values of all the checkboxes in a column */
$.fn.dataTable.ext.order['dom-checkbox'] = function  ( settings, col )
{
    return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) {
        return $('input', td).prop('checked') ? '1' : '0';
    } );
}

/* Initialise the table with the required column ordering data types */
$(document).ready(function() {
    $('#example').DataTable( {
        "columns": [
            { "orderDataType": "dom-checkbox" }
        ]
    } );
} );