Reputation: 3730
I want to add JSON data to a existing datatable.
The JSON data looks like this:
[
["Trident","Internet Explorer 4.0","Win 95+","4","X","X"],
["Trident","Internet Explorer 4.0","Win 95+","4","X","X"],
["Trident","Internet Explorer 4.0","Win 95+","4","X","X"],
["Trident","Internet Explorer 4.0","Win 95+","4","X","X"]
]
I tried:
$('#' + tab + '_table').dataTable().fnAddData(data);
data
is holding the JSON data.
Anything seems wrong there since it adds only one row with this:
Upvotes: 2
Views: 14142
Reputation:
It looks like you're asking dataTables to add raw JSON data to your table. You should parse it first with JSON.parse()
and add the resulting Javascript array.
var jsdata = JSON.parse(data);
$('#' + tab + '_table').dataTable().fnAddData(jsdata);
Upvotes: 6