foreach com datatable não funciona
Prezados,
Estou tentando usar o datatable com foreach no php e não funciona, ou melhor, funciona quando carrega apenas um registro, se existirem mais registros não funciona, quando recarrego a página para de funcionar tbm.
Podem ajudar?
Estou usando assim:
<table class="table table-responsive" id="tableIndexPedido">
<thead>
<tr>
<th>User</th>
<th>Data</th>
<th>Hora</th>
<th>Serviço</th>
<th data-priority="1">Açao</th>
</tr>
</thead>
<?php foreach ($this->pedido as $p): ?>
<tr>
<td><?= $p->getUser()->getNOME(); ?> </td>
<td><?= $p->getDATA_INICIO()->format("d/m/Y"); ?></td>
<td><?= $p->getHORA_INICIO()->format("H:i"); ?></td>
<td><h6><?= \wordwrap($p->getDESCRICAO(), 70, "<br>"); ?></h6></td>
<td>
<a href="<?= $this->url('servico', array('action' => 'pedidoServico', 'id' => $p->getIDPEDIDO())); ?>"><span class="label label-primary">Confirma</span></a>
<a href="<?= $this->url('user', array('action' => 'deletaPedidoServico', 'id' => $p->getIDPEDIDO())); ?>"><span class="label label-danger">Cancela</span></a>
</td>
</tr>
<?php endforeach; ?>
</table>
<script>
$(document).ready(function() {
$('#tableIndexPedido').dataTable({
"responsive": true,
"bPaginate": false,
"ordering": false,
"info": false,
"searching": false,
"columnDefs": [
{ responsivePriority: 1, targets: 0 },
{ responsivePriority: 2, targets: 4 }
]
} );
} );
</script>Discussão (0)
Carregando comentários...