In attempting to add a row to the jquery DataTable I am do the following:
//add new status row to the DataTable
$('#errorTable').dataTable().fnAddData( [
id,
msg,
tm
]);
I used to use the code below table.row.add([...])
to add a row - and it did work for awhile however all of the sudden it is giving me the following error:
Unhandled exception at line 102, column 17 in http://127.0.0.1:45319/js/errors.js?v=3
0x800a138f - JavaScript runtime error: Unable to get property 'add' of undefined or null reference
var table = $('#errorTable').dataTable();
table.row.add([
id,
msg,
tm
]).draw();
In fact doesn't the jQuery documentation use the table.row.add code in it's own example. My question is why doesn't it work and why does the fnAddData work? What am I missing or doing wrong?
Use DataTable()
to get access to newer API methods introduced in version 1.10+. For example:
var table = $('#errorTable').DataTable();
table.row.add([id, msg, tm]).draw();
You can continue using old API with dataTable()
, for example:
$('#errorTable').dataTable().fnAddData([id,msg,tm]);
User contributions licensed under CC BY-SA 3.0