我按照文档中的说明使用了数据表,但“搜索”无法正常工作,页面卡在了第1页上。
所有记录均显示。服务器端的响应似乎是正确的。
HTML
<link rel="stylesheet" type="text/css" href="bootstrap4/DataTables/datatables.css">
<script type="text/javascript" charset="utf8" src="bootstrap4/DataTables/datatables.js"></script>
<a onClick="openList();">Open Dialog</a>
<table id="itwr">
<thead>
<tr>
<th class="itwr_no">IT Work No.</th>
<th>Summary</th>
<th>Requested By</th>
<th>Req. Date</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
JS
function openList(){
$("#itwr").dataTable({
"bServerSide": true,
"lengthChange": false,
"retrieve":true,
"sAjaxSource": "dashboard.php?action=getITWR",
"aoColumns": [{
"mData": "itwr_no"
},{
"mData": "itwr_summary","width": "22%", "bSortable": true
},{
"mData": "itwr_requestedby"
},{
"mData": "request_date"
}]
});
}
PHP
$jsonRes["iTotalRecords"]=$i;
$jsonRes["iTotalDisplayRecords"]=10;
$jsonRes["sEcho"]= 1;
$jsonRes["aaData"]=$data;
echo json_encode($jsonRes);