fnAddData Error - Requested unknown parameter '0' from the data source for row 0
fnAddData Error - Requested unknown parameter '0' from the data source for row 0
NightStar
Posts: 2Questions: 0Answers: 0
Hi,
I'm trying to display a AJAX XML response in Datatables. I'm able to get table initialized. But the data is not being shown on the datable. I get warning [quote] DataTables warning (table id = 'notes'): Requested unknown parameter '0' from the data source for row 0 [/quote].
Here's the script I am trying to use.
[code]
$(document).ready(function() {
var thisTable;
thisTable = $('#notes').dataTable({
"sPaginationType" : "full_numbers",
"bJQueryUI" : true
});
$("#searchform").submit(function() {
$.ajax({
url : '../MyProject/data.xml',
type : "GET",
success : addToTable
});
return false;
});
function addToTable(response) {
var $processNotes = $(response).find("processNote");
$processNotes.each(function(index, processNote) {
var $processNote = $(processNote),
addData = [];
addData.push($processNote.attr("id"));
addData.push($processNote.children("name").text());
addData.push($processNote.children("text").text());
addData.push($processNote.children("status").text());
thisTable.fnAddData(thisTable,addData);
});
}
});
[/code]
Can some point the error in this code that is causing the data not to be displayed? I have same number of headers in HTML table as in Script. I could also see the parsed XML data assigned to addData array in Firebug.
I'm trying to display a AJAX XML response in Datatables. I'm able to get table initialized. But the data is not being shown on the datable. I get warning [quote] DataTables warning (table id = 'notes'): Requested unknown parameter '0' from the data source for row 0 [/quote].
Here's the script I am trying to use.
[code]
$(document).ready(function() {
var thisTable;
thisTable = $('#notes').dataTable({
"sPaginationType" : "full_numbers",
"bJQueryUI" : true
});
$("#searchform").submit(function() {
$.ajax({
url : '../MyProject/data.xml',
type : "GET",
success : addToTable
});
return false;
});
function addToTable(response) {
var $processNotes = $(response).find("processNote");
$processNotes.each(function(index, processNote) {
var $processNote = $(processNote),
addData = [];
addData.push($processNote.attr("id"));
addData.push($processNote.children("name").text());
addData.push($processNote.children("text").text());
addData.push($processNote.children("status").text());
thisTable.fnAddData(thisTable,addData);
});
}
});
[/code]
Can some point the error in this code that is causing the data not to be displayed? I have same number of headers in HTML table as in Script. I could also see the parsed XML data assigned to addData array in Firebug.
This discussion has been closed.
Replies
No need to pass 'thisTable' as the first parameter - just give it addData as per the docs: http://datatables.net/api#fnAddData :-).
Also, you should pass false as the second parameter to stop a redraw every time you add a new row in the loop as that would be really slow. Just add a call to fnDraw after the loop.
Allan
As I received oSettings as null, I tried passing thisTable.
fnDraw and passing false, did the trick for me :-)
Thanks much!
Great work on Datatables!