Addign a new row without reloading the ajax
Addign a new row without reloading the ajax
var table = $('#ProcedureLog').DataTable({
dom: "Bfrtip",
ajax: {
"url": "../ajax/at/ProcedureCancellationLog.php",
"type": "POST"
},
paging: false,
columns: [
{ data: "id" },
{ data: "Reason" },
],
select: true,
buttons: [],
});
lets say this is my table and I have a custom button to add a new entry in the ProcedureCancellationLog table. So, right nwo when i add a new entry on a different tab and come back to the datatable page tab i have added a event listener which reloads the ajax and get the new entry but is there a way where we can add a new enrty without reloading the ajax i..e manually looking for a new entry every 10-15 seconds same funcitonality as when we create a new entry inline it adds it witjout reloading the ajax.
table.button().add(
null, {
text: 'New',
action: function (e, dt, button, config) {
window.open("newDailyLog.php", "_blank");
}
});
Replies
Use
row.add()
to add one row orrows.add()
to add one or more rows from an array.Kevin