0
I have a data visualization page from a bd table, one of the cells in this table in html is actually a loop. I want to make the inline edition, which I’ve used in other projects (https://github.com/markcell/jquery-tabledit), but with all the fixed fields. This time, I don’t have all fixed tds, for example, if an agency has 10 protocols, 10 tds will be generated p it, if it has 1 will be generated 1 in the view.
Could someone give me a light on how to catch these ids?
Part of the table view, where the loop is
echo'<td>'.$turno.'</td>';
echo'<td>'.$funcionarios.'</td>';
echo'<td>'.$qt_col.'</td>';
echo'<td>'.$tipo_ocorrencia.'</td>';
//Busca as qtds de tipos de atividades cadastradas da agência para previstro e realizado
$dados3 = $pdo->prepare("SELECT * FROM protocolos_agencias where id_prot=:id_prot and tipo_ocorrencia=:tipo and status=1 ");
$dados3->bindParam(':id_prot',$id_prot, PDO::PARAM_INT);
$dados3->bindParam(':tipo',$tipo_ocorrencia, PDO::PARAM_STR);
$dados3->execute();
while($table3 = $dados3->fetch(PDO::FETCH_OBJ)){
echo'<td>'.$table3->qtd_atividades.'</td>';
}
echo'<td>'.$tempo.'</td>';
jquery editing script
<script>
$(document).ready(function(){
$('#example5').Tabledit({
url:'atividade/action.php',
columns:{
identifier:[0, 'id_registro'],
editable:[[2, 'atividade'], [3, 'turno'],[4, 'funcionarios'],[5, 'qtd'],[6, 'tipo'],[7, 'qtd_atividade'],[8,'tempo']]
},
restoreButton:false,
buttons:{
confirm: {
class: 'btn btn-sm btn-danger',
html: 'Desativar?'
},
delete:{
class: 'btn btn-sm btn-danger',
html: '<span class="glyphicon glyphicon-trash"></span>  ',
action: 'delete'
},
edit:{
class: 'btn btn-sm btn-success',
html: '<span class="glyphicon glyphicon-edit"></span>  ',
action: 'edit'
},
},
onSuccess:function(data, textStatus, jqXHR)
{
if(data.action == 'delete')
{
$('#'+data.id).remove();
}
}
});
});
</script>
The error is here: [7, 'qtd_atividade'],[8,'tempo']]
because if I have an agency with more than 1 type of activity, it won’t work.
first. The snippet does not support server side language. If you can in the table, show the generated HTML would be cooler... Regarding your demand, could you play an attribute in each td or in each input where you would put the id of what you want to change? If yes, it gets easier but laborious...
– DiegoSantos
@Diegosantos The table is immense, it has almost 30 fields. So, I didn’t post everything. : D So I wanted to make the update inline tb p look nicer for the user. So the problem is that the <td> type of activity, it varies from user. So I can give a fixed id, correct?
– Isadora Almeida