[英]How to do server-side processing using DataTAble in PHP?
I am trying to implement server-side processing of my data table but I am struggling with it.我正在尝试对我的数据表进行服务器端处理,但我正在努力解决它。 I don't have much to post because I couldn't really do anything but I am going to post my JS for the data table:
我没有太多要发布的内容,因为我真的什么也做不了,但我要发布数据表的 JS:
$(document).ready(function() {
var table = $('#dt-filter-select').DataTable({
"deferRender": true,
"order": [
[2, "desc"]
],
lengthChange: false
});
});
And the HTML table:和 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>
As mentioned here https://datatables.net/manual/data/ you shoud pass your data to the dataTable instance, instead of create a prefilled table and let the plugin to fill data正如这里提到的https://datatables.net/manual/data/你应该将你的数据传递给 dataTable 实例,而不是创建一个预填充表并让插件填充数据
something like this像这样的东西
$(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()) ?>
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.