1
I’m racking my brain with a little something in Codeigniter, I need to create an advanced table that expands details on each item of the table, as you can see in the code below I can’t separate a detail row for table item, att;
<div class="col-md-offset-2">
<div class="col-md-10">
<? //
$tmpl = array(
'table_open' => '<table class="table table-striped table-bordered table-hover" id="tabela_poas">',
'heading_row_start' => '<tr>',
'heading_row_end' => '</tr>',
'heading_cell_start' => '<th>',
'heading_cell_end' => '</th>',
'row_start' => '<tr data-toggle="collapse" data-target="#demo1">',
'row_end' => '</tr>',
'cell_start' => '<td align="center" role="row">',
'cell_end' => '</td>',
'row_alt_start' => '<tr>',
'row_alt_end' => '</tr>',
'cell_alt_start' => '<td align="center">',
'cell_alt_end' => '</td>',
'table_close' => '</table>'
);
// ?>
<script>
$(document).ready(function () {
// TableAdvanced.init('tabela_poas');
// iniciar_tabela('tabela_poas');
Init_mascaras_jquery();
TableAdvanced.init('tabela_poas');
});
// jQuery(document).ready(function () {
// Metronic.init(); // init metronic core components
// Layout.init(); // init current layout
// Demo.init(); // init demo features
//
// });
</script>
<input type="hidden" id="idquadro" value="<? // echo @$quadro_por_id[0]->IDQUADRO; ?>">
<div class="row">
<div class="col-md-12">
<? //
$detalhes = '
<div class="accordian-body collapse" id="demo1">
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th>Access Key</th>
<th>Secret Key</th>
<th>Status</th>
<th> Created</th>
<th> Expires</th>
</tr>
</thead>
<tbody >
<td class="details" colspan="5">
</td>
</tr>
</tbody>
</table>
</div>
';
if (isset($dados_produtos[0])) {
foreach ($dados_produtos as $row) {
$cell = array('data' => $detalhes, 'class' => 'highlight', 'colspan' => 7);
$this->table->set_template($tmpl);
$this->table->set_heading('IdItem', 'Modalidade', 'Área', 'Titulo', 'Beneficiário', 'Valor Aprovado', 'Detalhes');
$this->table->add_row(
@$row->idpoaitem,
@$row->modalidade,
@$row->area,
@$row->titulo,
@$row->beneficiario,
@$row->valoraprovado,
' <button class="btn btn-default btn-xs"><span class="glyphicon glyphicon-eye-open"></span>
</button>'
);
$this->table->add_row($cell);
}
}
?>
</div>
</div>
<? echo $this->table->generate() . '<br><br>'; ?>
</div>
I can tell you you won’t be able do something like this using the native class of
CodeIgniter
because it does not allow changing the attributes of the generated table rows (which is unfortunate because it allows changing thecells
). The solution is to extend or replace. Extend is better because you do not touch the base of theframework
.– ShutUpMagda