任何想法,線索當我點擊具有「show_all_records」ID的按鈕時如何顯示所有記錄?並且如果我單擊具有「restore_records」標識的按鈕,則數據表格表將在其默認狀態下恢復,例如,記錄設置回默認狀態。顯示數據表上的所有記錄當點擊按鈕
我可以使用「分頁:錯誤/真實」,但我不知道如何以現場方式應用它。
$(document).ready(function(){
$('#sample_table').DataTable({
"bSort": false,
"pagingType": "full_numbers",
"dom": 'T<"clear">lfrtip',
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://cdn.datatables.net/r/dt/dt-1.10.8/datatables.min.css" rel="stylesheet"/>
<script src="https://cdn.datatables.net/r/dt/dt-1.10.8/datatables.min.js"></script>
<table cellpadding="0" cellspacing="0" id="sample_table">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Branch</th>
<th>Department</th>
</tr>
</thead>
<tbody>
<tr>
<td>Sample Name 1</td><td>Sample position</td><td>sample branch</td><td>sample department</td>
</tr>
<tr>
<td>Sample Name 1</td><td>Sample position</td><td>sample branch</td><td>sample department</td>
</tr>
<tr>
<td>Sample Name 1</td><td>Sample position</td><td>sample branch</td><td>sample department</td>
</tr>
<tr>
<td>Sample Name 1</td><td>Sample position</td><td>sample branch</td><td>sample department</td>
</tr>
<tr>
<td>Sample Name 1</td><td>Sample position</td><td>sample branch</td><td>sample department</td>
</tr>
<tr>
<td>Sample Name 1</td><td>Sample position</td><td>sample branch</td><td>sample department</td>
</tr>
<tr>
<td>Sample Name 1</td><td>Sample position</td><td>sample branch</td><td>sample department</td>
</tr>
<tr>
<td>Sample Name 1</td><td>Sample position</td><td>sample branch</td><td>sample department</td>
</tr>
<tr>
<td>Sample Name 1</td><td>Sample position</td><td>sample branch</td><td>sample department</td>
</tr>
<tr>
<td>Sample Name 1</td><td>Sample position</td><td>sample branch</td><td>sample department</td>
</tr>
<tr>
<td>Sample Name 1</td><td>Sample position</td><td>sample branch</td><td>sample department</td>
</tr>
<tr>
<td>Sample Name 1</td><td>Sample position</td><td>sample branch</td><td>sample department</td>
</tr>
<tr>
<td>Sample Name 1</td><td>Sample position</td><td>sample branch</td><td>sample department</td>
</tr>
<tr>
<td>Sample Name 1</td><td>Sample position</td><td>sample branch</td><td>sample department</td>
</tr>
<tr>
<td>Sample Name 1</td><td>Sample position</td><td>sample branch</td><td>sample department</td>
</tr>
<tr>
<td>Sample Name 1</td><td>Sample position</td><td>sample branch</td><td>sample department</td>
</tr>
<tr>
<td>Sample Name 1</td><td>Sample position</td><td>sample branch</td><td>sample department</td>
</tr>
<tr>
<td>Sample Name 1</td><td>Sample position</td><td>sample branch</td><td>sample department</td>
</tr>
<tr>
<td>Sample Name 1</td><td>Sample position</td><td>sample branch</td><td>sample department</td>
</tr>
<tr>
<td>Sample Name 1</td><td>Sample position</td><td>sample branch</td><td>sample department</td>
</tr>
<tr>
<td>Sample Name 1</td><td>Sample position</td><td>sample branch</td><td>sample department</td>
</tr>
<tr>
<td>Sample Name 1</td><td>Sample position</td><td>sample branch</td><td>sample department</td>
</tr>
<tr>
<td>Sample Name 1</td><td>Sample position</td><td>sample branch</td><td>sample department</td>
</tr>
<tr>
<td>Sample Name 1</td><td>Sample position</td><td>sample branch</td><td>sample department</td>
</tr>
<tr>
<td>Sample Name 1</td><td>Sample position</td><td>sample branch</td><td>sample department</td>
</tr>
<tr>
<td>Sample Name 1</td><td>Sample position</td><td>sample branch</td><td>sample department</td>
</tr>
<tr>
<td>Sample Name 1</td><td>Sample position</td><td>sample branch</td><td>sample department</td>
</tr>
<tr>
<td>Sample Name 1</td><td>Sample position</td><td>sample branch</td><td>sample department</td>
</tr>
<tr>
<td>Sample Name 1</td><td>Sample position</td><td>sample branch</td><td>sample department</td>
</tr>
<tr>
<td>Sample Name 1</td><td>Sample position</td><td>sample branch</td><td>sample department</td>
</tr>
<tr>
<td>Sample Name 1</td><td>Sample position</td><td>sample branch</td><td>sample department</td>
</tr>
<tr>
<td>Sample Name 1</td><td>Sample position</td><td>sample branch</td><td>sample department</td>
</tr>
<tr>
<td>Sample Name 1</td><td>Sample position</td><td>sample branch</td><td>sample department</td>
</tr>
<tr>
<td>Sample Name 1</td><td>Sample position</td><td>sample branch</td><td>sample department</td>
</tr>
<tr>
<td>Sample Name 1</td><td>Sample position</td><td>sample branch</td><td>sample department</td>
</tr>
<tr>
<td>Sample Name 1</td><td>Sample position</td><td>sample branch</td><td>sample department</td>
</tr>
<tr>
<td>Sample Name 1</td><td>Sample position</td><td>sample branch</td><td>sample department</td>
</tr>
<tr>
<td>Sample Name 1</td><td>Sample position</td><td>sample branch</td><td>sample department</td>
</tr>
<tr>
<td>Sample Name 1</td><td>Sample position</td><td>sample branch</td><td>sample department</td>
</tr>
<tr>
<td>Sample Name 1</td><td>Sample position</td><td>sample branch</td><td>sample department</td>
</tr>
</tbody>
</table>
<button id="show_all_records">show all records</button>
<button id="restore_records">Restore records on its default state</button>
輝煌!無論如何,我得到了這個錯誤「不能轉換undefined或空對象」雖然它的工作 –
控制檯錯誤?錯誤指向哪裏? –
jQuery-2.1.3.min.js:3 Uncaught TypeError:無法將undefined或null轉換爲對象 –