There are several issues here:
In my opinion this line var matT = "<tr></td>";
should not carry the </td>
and should be within the cycle each
. The <tr>
must be in a cycle for the rows to be created, within that cycle and the 15 td of opening and closing with its content must be put.
You can not make indented tables (well, they should not be done), because you will have many problems. If you define 15 columns, all rows will have 15 columns, or if they are 10, they will all have ten. If you know the number of columns put the 15, but if you can vary in each construction of the table, you need another cycle.
But in order for you to receive a good help we need to see that it brings the variable datos
.
I create an empty table in javascript that is then filled with a jquery datatables as follows:
var txtTemp;
var thTemp;
var tblHead = document.createElement("thead");
var filaHead = document.createElement("tr");
var encabezados=new Array("COLUMNA1","COLUMNA2","COLUMNA3","COLUMNAN",);
tabla = document.createElement("table");
tabla.setAttribute("cellpadding", "0");
tabla.setAttribute("cellspacing", "0");
tabla.setAttribute("border", "0");
tabla.setAttribute("id", "tblRevalidacion");
tabla.setAttribute("class", "display");
tabla.setAttribute("width", "100%");
filaHead.setAttribute("class", "display");
for(var i=0;i<encabezados.length;i++){
txtTemp=document.createTextNode(encabezados[i]);
thTemp=document.createElement("th");
thTemp.appendChild(txtTemp);
filaHead.appendChild(thTemp);
}
tblHead.appendChild(filaHead);
tabla.appendChild(tblHead);
var divAplicacion = document.getElementById("aplicacion");
divAplicacion.appendChild(tabla);
To do this add a div id=aplicación
to the html and the table is generated within it. My table only has the headers because I'll tell you later I'll fill it with a jquery datatables. It would also be good if you made a console.log(matT)
to see how your table is and do not walk blind.