Mudanças entre as edições de "Criar formulário no site da FAHOR - Joomla - Exemplo de uma listagem de dados"
Ir para navegação
Ir para pesquisar
(Criou página com 'Para fazer uma listagem de dados, basta associar uma consulta como JSON ao pluguin DataTable, conforme abaixo:') |
|||
Linha 1: | Linha 1: | ||
− | Para fazer uma listagem de dados, basta associar uma consulta como JSON ao | + | * Para fazer uma listagem de dados, basta associar uma consulta como JSON ao plugin DataTable, conforme abaixo: |
+ | <syntaxhighlight lang="php"> | ||
+ | {source 0}<?php | ||
+ | $egressos = simpleXMLTBCtoArray(getXMLFromTBC('FAHOR.TBC.004', 7, 'S', '')); | ||
+ | ?>{/source} | ||
+ | </syntaxhighlight> | ||
+ | <syntaxhighlight lang="html"> | ||
+ | <table id="egressos" class="display" cellspacing="0" width="100%"> | ||
+ | <thead> | ||
+ | <tr> | ||
+ | <th>Egresso</th> | ||
+ | <th>Curso</th> | ||
+ | <th>Ano de Colação</th> | ||
+ | </tr> | ||
+ | </thead> | ||
+ | <tbody> | ||
+ | </tbody> | ||
+ | </table> | ||
+ | </syntaxhighlight> | ||
+ | <syntaxhighlight lang="javascript"> | ||
+ | <script> | ||
+ | var egressos = {source 0}<?php echo json_encode($egressos); ?>{/source} | ||
+ | jQuery('#egressos').DataTable({ | ||
+ | data: egressos, | ||
+ | pageLength : 25, | ||
+ | responsive: true, | ||
+ | order: [[0, 'asc']], | ||
+ | columns: [ | ||
+ | {data:'nome', width:'50%', className:'dt-head-center'}, | ||
+ | {data:'curso', width:'30%', className:'dt-head-center dt-body-left'}, | ||
+ | {data:'anocolacao', width:'20%', className:'dt-center'} | ||
+ | ] | ||
+ | }); | ||
+ | jQuery('#egressos').removeClass('display').addClass('table table-striped table-bordered'); | ||
+ | </script> | ||
+ | </syntaxhighlight> |
Edição das 10h50min de 7 de fevereiro de 2018
- Para fazer uma listagem de dados, basta associar uma consulta como JSON ao plugin DataTable, conforme abaixo:
{source 0}<?php
$egressos = simpleXMLTBCtoArray(getXMLFromTBC('FAHOR.TBC.004', 7, 'S', ''));
?>{/source}
<table id="egressos" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>Egresso</th>
<th>Curso</th>
<th>Ano de Colação</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<script>
var egressos = {source 0}<?php echo json_encode($egressos); ?>{/source}
jQuery('#egressos').DataTable({
data: egressos,
pageLength : 25,
responsive: true,
order: [[0, 'asc']],
columns: [
{data:'nome', width:'50%', className:'dt-head-center'},
{data:'curso', width:'30%', className:'dt-head-center dt-body-left'},
{data:'anocolacao', width:'20%', className:'dt-center'}
]
});
jQuery('#egressos').removeClass('display').addClass('table table-striped table-bordered');
</script>