4
Good morning guys,
I’ll get straight to the point... I have this Success from my json where validating the following function:
for(i=0; data.length>i ;i++)
{
let cliente = data[i].item;
let totais = {};
data[i].item.forEach(i => {
if(! totais[i.projeto])
{
totais[i.projeto] = '';
}
totais[i.projeto] = i.cliente ;
});
Object.keys(totais).forEach(l =>{
let clientes = totais[l];
$('#tabela').append('<table class="table table-light" id="table'+data[i].projeto+'"><thead class = "thead-dark"><tr><th>'+clientes+'-'+data[i].projeto+'</th><th></th><th></th><th></th><th></th><th></th></thead>');
});
for(j = 0; j < cliente.length; j++)
{
$('#table'+data[i].projeto).append('<tbody><tr><td>'+cliente[j].nome+'</td><td>'+cliente[j].desc+'</td><td>'+cliente[j].type+'</td><td>'+cliente[j].start+'-'+cliente[j].end+'</td><td>'+cliente[j].duration+'</td><td class="ml-auto text-right"><buttom class="btn btn-primary mr-2 botao" id="edit"><i class="fas fa-user-edit"></i></buttom><buttom class="btn btn-danger botao" id="remove"><i class="fas fa-user-times"></i></i></buttom></td></tbody></table>');
console.log(cliente[j].nome)
}
}
However, the last option does not appear in the table, but in the console.log the result appears. As in the image below, someone could give me a north of what can be done?
The json is like this:
[{"projeto":"TimeSheet","item":[{"id":"8","nome":"TimeTrack","desc":"Cria\u00e7\u00e3o da time track","info":"","type":"programa\u00e7\u00e3o","start":"16\/08\/2019","end":"21\/08\/2019","duration":"120:00","cliente":"Carlos","projeto":"TimeSheet","usuarios":"Diego, Anderson"},{"id":"10","nome":"Dashboard","desc":"Cria\u00e7\u00e3o da dashboard","info":"","type":"programa\u00e7\u00e3o","start":"16\/08\/2019","end":"21\/08\/2019","duration":"20:00","cliente":"Carlos","projeto":"TimeSheet","usuarios":"Diego"},{"id":"11","nome":"Pacote","desc":"Cria\u00e7\u00e3o tela de pacote","info":"","type":"programa\u00e7\u00e3o","start":"19\/08\/2019","end":"22\/08\/2019","duration":"96:00","cliente":"Carlos","projeto":"TimeSheet","usuarios":"Diego, Anderson, Marcelo"}]},{"projeto":"Software","item":[{"id":"14","nome":"Software Line","desc":"Cria\u00e7\u00e3o da tela do software","info":"","type":"programa\u00e7\u00e3o","start":"16\/08\/2019","end":"22\/08\/2019","duration":"120:00","cliente":"Carlos","projeto":"Software","usuarios":"Diego,"}]},{"projeto":"Aplicativo Mobile","item":[{"id":"13","nome":"Aplicativo Mobile","desc":"Cria\u00e7\u00e3o de um app","info":"","type":"programa\u00e7\u00e3o","start":"21\/08\/2019","end":"22\/08\/2019","duration":"24:00","cliente":"Marcelo","projeto":"Aplicativo Mobile","usuarios":"Diego, Anderson"}]}]
Maybe it’s the
data.length>i, mude para
data.length>=i` and see if it worked.– Edward Ramos
It doesn’t work, it stops going through my value and only goes through my key.
– Diêgo Correia de Andrade
If you print the
i
, How many does it go? Of the first one is– Edward Ramos
It comes my json... normal, the point is that it just doesn’t print in the table of the Mantle, but its data comes quietly.
– Diêgo Correia de Andrade
And go to number 2
– Diêgo Correia de Andrade
Ask a JSON sample.
– Sam
@Sam, I posted my json.
– Diêgo Correia de Andrade
"Last option" that you refer would be a line below "Marcelo-Mobile App"?
– Sam
@Sam that, that line!
– Diêgo Correia de Andrade