2016-09-06 58 views
2

我正在使用datatable 1.10。我已經創建了一個表格,但是我無法設法在其行上執行多個「shift select」。DataTables:移位多選不工作

根據該數據表文檔:

TableTools has four row selection modes of operation: 
    none - Default, where no user row selection options are available 
    single - A single row can be selected 
    multi - Multiple rows can be selected simply by clicking on the rows 
    os - Operating System like selection where you can use the shift and ctrl/cmd keys on your keyboard to add/remove rows from the selection. 

所以我創造我的表如下:

$("#my-table-div").DataTable({ 
    "retrieve": true, 
    "pagingType": "full_numbers", 
    "pageLength": 50, 
    "lengthMenu": [50, 100, 200], 
    "dom": '<lfi<t>p>', 
    "autoWidth": false, 
    "columns": columnsTable, 
    "tableTools": { 
     "sRowSelect": "os" 
    } 
}); 

正如你所看到的,我使用的是"sRowSelect": "os",但它肯定是不作爲工作我渴望。我無法讓「班次選擇」工作。

關於我失蹤或做錯的任何想法?

+1

如果您使用的是數據表1.10,則根本不應該使用TableTools;這是按鈕和選擇前的1.10擴展名。你應該使用Select擴展,記錄[這裏](https://datatables.net/extensions/select/) –

回答

2

這裏是一個live example,您需要添加dataTables.select.min.js資源來管理選擇選項。你的選擇:"columns": columnsTable是有問題的。

$(document).ready(function() { 
    $('#example').DataTable({ 
     "retrieve": true, 
     "pagingType": "full_numbers", 
     "pageLength": 50, 
     "lengthMenu": [50, 100, 200], 
     "dom": '<lfi<t>p>', 
     "autoWidth": false, 
     //"columns": columnsTable, <-- options problem 
     "select": { 
      "style": "os" 
     } 
    }); 
}); 
+0

'「columns」:columnsTable'不是必然的問題,只要它們有一個對象在表初始化之前定義的正確語法。 –