1
Good afternoon to you... I need to create a table where the rows and columns are created dynamically. For example, consider this JSON:
{"employees":[
    {"firstName":"John", "lastName":"Doe"},
    {"firstName":"Anna", "lastName":"Smith"},
    {"firstName":"Peter", "lastName":"Jones"}
]}
and the JS code
var table = '<div class=\'dataTables\'>';
         *      table += '<div class=\'table-responsive\'>';
         *      table += '<table id=\'tabela\' style=\'white-space: nowrap;\' cellspacing=\'0\' width=\'100%\' class=\'table table-hover table-striped table-bordered\'>';
         *      table += '<thead>';
                     //criar o cabecalho de acordo com o JSON
                table += '</thead>';
         *      table += '<tfoot><tr class=\'tr-foot\' id=\'tFoot\'></tr></tfoot>';
         *      table += '<tbody>';
         *          
         *          //criar as linhas de acordo com o json
         *          
         *      table += '</tbody>'
         *      table += '</table>';
         *      table += '</div>';
         *      table += '</div>';
I’m having more difficulty creating the columns, with their headers, because I don’t know how to read this json in order to check the amount of column and only take the "Header" to put in the table.
BS: I don’t want to leave static columns in the table.
Does this json have no commas among objs? Post the correct json sff, to my mind that’s 4 different jsons
– Miguel
Come on, I changed the json buddy
– Jeterson Miranda Gomes