我正在尝试对我的数据表进行服务器端处理,但是我正为此而苦苦挣扎。我没有太多要发布的内容,因为我什么都做不了,但是我要为数据表发布我的JS:
$(document).ready(function() {
var table = $('#dt-filter-select').DataTable({
"deferRender": true,
"order": [
[2, "desc"]
],
lengthChange: false
});
});
和HTML表格:
<table id="dt-filter-select" class="display" style="width:100%">
<thead>
<tr>
<th>Admin</th>
<th>Log text</th>
<th>Timestamp</th>
</tr>
</thead>
<tbody>
<?php foreach (get_all_log_history() as $logs) : ?>
<tr>
<td>
<?php echo $logs["name"]; ?>
</td>
<td>
<?php echo $logs["log_text"]; ?>
</td>
<td>
<?php echo $logs["log_time"]; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
<tfoot>
<tr>
<th>
</th>
</tr>
</tfoot>
</table>
答案 0 :(得分:0)
如此处https://datatables.net/manual/data/所述,您应该将数据传递到dataTable实例,而不是创建一个预填充表并让插件填充数据
类似的东西
$(document).ready(function() {
var table = $('#dt-filter-select').DataTable({
"deferRender": true,
"order": [
[2, "desc"]
],
lengthChange: false,
data: <?php echo json_parse(echo get_all_log_history()) ?>
});
});