Let me begin by outlining the process I am undertaking. I interact with a remote JSON API to retrieve data, perform some basic operations on it, and ultimately produce a data row consisting of three variables: Date, name, and message (think of an IRC chat room). My goal is to exhibit this information in a searchable data table, but I am encountering difficulties when attempting to add a row to said table. Presently, my HTML structure resembles the following:
<table id="table" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>Date</th>
<th>Name</th>
<th>Message</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Date</th>
<th>Name</th>
<th>Message</th>
</tr>
</tfoot>
</table>
In addition, here is an excerpt from my JavaScript code:
var text = document.getElementById('text'); //Text Div
var nameguest = data.items[i].from; //Guests
var nameuser = data.items[i].from.name; //Users
var message = data.items[i].message; //Messages
changeDate(data.items[i].date); //Date
var table = document.getElementById("table"); //Table Div
var row = table.insertRow(i);
row.insertCell(0).innerHTML = datehuman;
if (typeof nameguest == "object") {
row.insertCell(1).innerHTML = nameuser;
} else {
row.insertCell(1).innerHTML = nameguest;
}
row.insertCell(2).innerHTML = message;
}
}
I would like to inquire if there exists equivalent functionality akin to insertCell(0).innerHTML
tailored for datatables?