Reputation: 183829
How does one dynamically create table cells based on a dataset? Is Javascript/ajax required for this? Is it possible to use a template div for the cells?
Just looking for some direction.
Upvotes: 0
Views: 549
Reputation: 22436
If you want to dynamically create table cells, you need to manipulate the DOM, so you need Javascript.
An example, which will add a new row to a table:
var table = document.getElementById('[tablebodyelement]'),
row = document.createElement('tr'),
data = ["cell1", "cell2", "cell3"];
for(var i=0; i<row.length; i++){
var cell = document.createElement('td');
td.appendChild(document.createTextnode(row[i]));
row.appendChild(td);
}
table.appendChild(row);
Upvotes: 1