Error while trying to add a new row in a DataTable
Error while trying to add a new row in a DataTable
I have the dataSource defined as
[code]function getData(){
var arr = [];
for(var i=0; i<1000; i++){
var obj = {
'name': 'John', 'company' : 'ABC Corp', 'salary': '$x'
};
arr.push(obj);
}
return arr;
}[/code]
The table is being rendered as
[code]
var arr = getData();
$('#table1').dataTable({
'aaData': arr,
'aoColumns': [
{'sTitle': 'name'},
{'sTitle': 'company'},
{'sTitle': 'salary'}
]
})[/code]
Now when i try to add a new row to the dataTable as
[code]
$('#table1').dataTable.fnAddData([
" ", " ", " "
]);
[/code]
I get an error as
DataTables warning (table id = 'table1'): Requested unknown parameter 'name' from the data source for row 1001
What can be causing this?
[code]function getData(){
var arr = [];
for(var i=0; i<1000; i++){
var obj = {
'name': 'John', 'company' : 'ABC Corp', 'salary': '$x'
};
arr.push(obj);
}
return arr;
}[/code]
The table is being rendered as
[code]
var arr = getData();
$('#table1').dataTable({
'aaData': arr,
'aoColumns': [
{'sTitle': 'name'},
{'sTitle': 'company'},
{'sTitle': 'salary'}
]
})[/code]
Now when i try to add a new row to the dataTable as
[code]
$('#table1').dataTable.fnAddData([
" ", " ", " "
]);
[/code]
I get an error as
DataTables warning (table id = 'table1'): Requested unknown parameter 'name' from the data source for row 1001
What can be causing this?
This discussion has been closed.
Replies
Allan