Added Data Warning
Added Data Warning
I'm going to go ahead and apologize for posting this, as I'm sure I am doing something stupid...but anyway, whenever I load data via sAjaxSource, I get the following warning:
"Warning - Added data does not match known number of columns."
My code is:
[code]
$(document).ready(function() {
$('#userTable').dataTable({
"bProcessing": true,
"bServerSide": true,
"aoColumns": [
{ "sTitle": "Name" },
{ "sTitle": "BprNumber" }
],
"sAjaxSource": "http://[Domain]/Admin/GetUsers",
"bJQueryUI": true,
"bLengthChange": false,
"bFilter": false
});
});
[/code]
[code]
Name
BprNumber
[/code]
The JSON sent back (via Fiddler2 and validated at JSONLint.com) is:
[code]
{
"sEcho": 1,
"iTotalRecords": 2,
"iTotalDisplayRecords": 2,
"aaData": [
{
"Name": "Henderson, Ben",
"BprNumber": null
},
{
"Name": "Ferrise, Sam",
"BprNumber": 0
}
]
}
[/code]
Any idea on what I'm doing wrong? This is causing frustration, because the AJAX method is called correctly, JSON is returned, and upon further investigation within the Data Tables JS file, the data object is undefined...?
Thanks
Sam
"Warning - Added data does not match known number of columns."
My code is:
[code]
$(document).ready(function() {
$('#userTable').dataTable({
"bProcessing": true,
"bServerSide": true,
"aoColumns": [
{ "sTitle": "Name" },
{ "sTitle": "BprNumber" }
],
"sAjaxSource": "http://[Domain]/Admin/GetUsers",
"bJQueryUI": true,
"bLengthChange": false,
"bFilter": false
});
});
[/code]
[code]
Name
BprNumber
[/code]
The JSON sent back (via Fiddler2 and validated at JSONLint.com) is:
[code]
{
"sEcho": 1,
"iTotalRecords": 2,
"iTotalDisplayRecords": 2,
"aaData": [
{
"Name": "Henderson, Ben",
"BprNumber": null
},
{
"Name": "Ferrise, Sam",
"BprNumber": 0
}
]
}
[/code]
Any idea on what I'm doing wrong? This is causing frustration, because the AJAX method is called correctly, JSON is returned, and upon further investigation within the Data Tables JS file, the data object is undefined...?
Thanks
Sam
This discussion has been closed.
Replies
This error occurs when you have a different number of columns being passed around. Looking at your code samples, I don't really see where this would be though, other than the 'null'. DataTables doesn't like null values, since it doesn't mean anything to the table - it should either be a blank string or 0 or the like (how would it present null to the end user, or sort on it etc, for example).
If that doesn't fix it, please post back so as I can dig deeper, as I'm curious to know what is causing this!
Regards,
Allan