i have a matrix of objects:
var data = [[
{"value": "1"},
{"value": "2"},
{"value": "2"},
{"value": "4"}
], [
{"value": "1"},
{"value": "2"},
{"value": "2"},
{"value": "4"}
], [
{"value": "1"},
{"value": "3"},
{"value": "3"},
{"value": "5"}
]];
and I would like to render the matirx out as a html table with combined cells.
The sample of rendering matrix to htm table with separated cells:
var data = [[
{"value": "1"}, {"value": "1"}, {"value": "1"}
], [
{"value": "2"}, {"value": "2"}, {"value": "3"}
], [
{"value": "2"}, {"value": "2"}, {"value": "3"}
], [
{"value": "4"}, {"value": "4"}, {"value": "5"}
]];
function renderCombinedTable(data) {
// TODO : realize
}
function renderSeparatedTable(data) {
var xTable = document.createElement("table");
for (var i = 0, ii = data.length; i < ii; i++) {
xTable.appendChild(xTRs = document.createElement("tr"));
for (var j = 0, jj = data[i].length; j < jj; j++) {
var xTD = document.createElement("td");
xTD.appendChild(document.createTextNode(data[i][j].value));
xTRs.appendChild(xTD);
}
}
return xTable;
}
document.body.appendChild(renderSeparatedTable(data));
td {
border: solid 1px;
}
How do I get the table with combined cells?
I want the output to look something like this: