I'm creating a PivotTable from the values of an object, but at the time of generating the table it does not appear. Here is the code:
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><scriptsrc="batata.js"></script>
</head>
<body>
<div id="tbldados"></div>
</body>
</html>
--------------------------------------------------------------------------------
var dados =[{
"N1":" CONTROLE DE GESTÃO ORCAMENTARIA CONCESSÕES - INDICADORES / 2017 (MILHARES R$)",
"N2":" ",
"N3":"A1 - ATIVIDADE CORE",
"ANO_ANTERIOR":1214363,
"ANO_ATUAL":1335800,
"VAR":121437,
"JAN":2388000,
"FEV":2268000,
"MAR":1728000,
"ABR":2424000,
"MAI":1464000,
"JUN":2124000,
"JUL":1212000,
"AGO":1356000,
"SET":2400000,
"OUT":1800000,
"NOV":0,
"DEZ":0,
"TOTAL":456291000
}]
function createTable(obj){
// Criar a table
$('#tbldados').append('<table></table>'); // Adiciona a tabela ao body
var table = $('#tbldados').children('table'); // Seleciona a tabela
// Criar o head da table
var thead = "<tr>";
for (coluna in obj[0]) {
thead += "<th>" + coluna + "</th>";
}
thead += "</tr>";
$("<table>").show();
//Criar o body da table
var tbody = "<tr>";
obj.forEach(function(linha,) {
for (item in linha) {
tbody += "<td>" + linha[item] + "</td>";
}
tbody += "</tr>";
})
// Adiciona a tabela completa ao body
}
$(document).ready(function(){
createTable(dados);
});