2016-11-16 64 views
0

我看了教程https://www.datatables.net/examples/plug-ins/dom_sort.html按列複選框值排序表

但是缺少複選框的示例。 我試過這個

/* 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'; 
    }); 
} 

$('#filterResultTable').DataTable({ 
      "sDom": "H", // remove header (record count + search textbox) 
      "paging": false, // show all records on 'first' page 
      "order": [[1, "asc"]], // default order bis by 2nd column, 
      "aoColumns": [ 
       { "orderDataType": "dom-checkbox" }, 
       null, 
       null, 
       null, 
       null, 
       null, 
       null 
      ] 
}); 

但沒有運氣,這裏沒有明顯的錯誤。 有什麼想法?

回答

0

您需要使用columns屬性而不是aoColumns屬性。