我希望你们一切都好。
我正在编辑一个用PHP-Codeigniter构建的CRM。有很多表都呈现为jQuery dataTable
。他们所做的是页面加载时,它通过ajax调用PHP,并将数据加载到表中。但是,在我要创建的页面上,我想在页面加载之前先加载数据(在控制器中并将其传递给视图),然后在其上应用dataTable
。我之前已经使用了很多次,但是不幸的是我现在无法使用它。我想我必须禁用某种触发ajax的dataTable标志。
我的代码如下所示
<table class="table table-condensed table-stripped logsTable">
<thead>
<tr>
<th>#</th>
<th>From</th>
<th>To</th>
<th>Date</th>
<th>Duration</th>
<th>Direction</th>
<th>Recording</th>
</tr>
</thead>
<tbody>
<?php
$c = 1;
foreach ($logs['calls'] as $call){
?>
<tr>
<th><?php echo $c;?></th>
<th><?php echo $call['from_number'];?></th>
<th><?php echo $call['to_number'];?></th>
<th><?php echo date("d M, y - h:i A", strtotime($call['datestring']));?></th>
<th><?php echo gmdate("H:i:s", $call['duration']);?></th>
<th><?php echo $call['direction'];?></th>
<th><a href="<?php echo $call['duration']?>">Open</a></th>
</tr>
<?php
$c++;
}
?>
</tbody>
<tfoot></tfoot>
</table>
JS是:
$(".logsTable").DataTable();
它应该将表的格式设置为dataTable
,但它只会继续显示加载布局,而不会显示数据。任何帮助将不胜感激。我想我需要在某个地方进行配置,以告诉它不要通过Ajax从服务器获取数据。我已经尝试过通过"processing": true,"serverSide": false,
了,但是没有成功。