我知道這看起來原始的「檢查所有」,但我一直在努力執行了整整一天,也許是因爲我不能完全理解如何使用API,我使用數據表1.10.0,我有分頁功能表中,每一行中有一個複選框,我需要有一個「檢查所有按鈕」,將您在網頁中的所有複選框,問題是它只檢查的複選框在當前頁面中,並且其他頁面未被選中,這應該很容易,但我無法弄清楚!答案我發現使用「fnGetNodes」,這似乎是過時和不使用的版本1.10數據表1.10通過jQuery
編輯:這是我的標記
<table class="table table-striped table-bordered table-hover" id="numbers_table">
<thead>
<tr>
<th><input type="checkbox" id="checkall" title="Select all" onClick="toggle(this)"/></th>
<th>Number</th>
<th>Company</th>
<th>Tags</th>
</tr>
</thead>
<tbody>
<% _.each(array, function (value) { %>
<tr>
<td><input type='checkbox' name='numbers[]' value='<%=value.id%>'/></td>
<td><%= value.number %></td>
<td><%= value.company %></td>
<td><%= value.tags %></td>
</tr>
<% }) %>
</tbody>
</table>
<button type="button" class="btn btn-primary" id="checkall2">SELECT ALL</button>
<script>
$(document).ready(function() {
$('#numbers_table').dataTable({
//"bPaginate": false,
"aoColumnDefs": [
{ "bSortable": false, "aTargets": [ 0 ] }
]
});
$("#checkall2").click(function() { // a button with checkall2 as its id
$(':checkbox').prop('checked', true); // all checkboxes, you can narrow with a better selector
});
});
</script>
請提供更多的細節,比如實際的代碼你使用。 –
@LaughDonor我添加的代碼^ – mbahaa