Error When Adding Row to Table
Error When Adding Row to Table

I get this error when trying to add a row to table, but not sure how to solve it.
Uncaught Error: DataTables warning: table id=eventtime_details - Requested unknown parameter 'eventtime' for row 2, column 0. For more information about this error, please see http://datatables.net/tn/4
The table I am attempting to add a row to is as follows:
var oEventSchedulerDetailsTable = $('#eventtime_details').DataTable( {
info: false,
paging: false,
select: {
"info": false
},
"language": {
"emptyTable": "No times scheduled"
},
searching: false,
processing: true,
columns: [
{ data: 'eventtime', title: 'Time' }, // Row 0
{ data: 'execute_on', title: 'Execute on' }, // Row 1
{ data: 'id', visible: false, searchable: false }, // Row 2
{ data: 'eventid', visible: false, searchable: false }, // Row 3
{ data: 'eventdate', visible: false, searchable: false }, // Row 4
{ data: 'eventday', visible: false, searchable: false }, // Row 5
{ data: 'recurring', visible: false, searchable: false } // Row 6
]
});
And the code I am using to add the row:
oEventSchedulerDetailsTable.row.add( [
eventtime,
execute_on,
'',
$('#eventid').val(),
$('#eventdate').val(),
$('#eventday').val(),
$('#eventrecurring').val()
] ).draw();
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
You are using
columns.data
because you have object structured data. When using -api row.add()` you need to match that structure meaning you need to add an object not an array.Kevin
So, this may look a little ugly but just testing. I changed the
row.add()
to this but still no success:This part of the statement is creating an array:
The
row.add()
API expects one row of data. In your case that needs to be an object. Therows.add()
, plural rows, expects an array of one or more rows where each row is an array or object. For the above you need to userows.add()
. See the examples in the docs for both API's.Kevin
Thanks for the help. For whatever the reason, I just was not seeing it yesterday, but with a night of rest, I finally saw what I needed to do to get it working.
This works: