DataTables warning (table id = '.....'): Requested unknown parameter '0' from the data so
DataTables warning (table id = '.....'): Requested unknown parameter '0' from the data so
I've tried to find out, what is the main source of this error, because it is getting me nowhere.
My reponse is this:
{
"data":
[{"column1":"value","column2":"value" ...... ,"column9":"value"}],
[{"column1":"value","column2":"value" ...... ,"column9":"value"}],
.....
[{"column1":"value","column2":"value" ...... ,"column9":"value"}],
}
I've checked that number of columns are correct and that there are no null values (found on some forums as posssible fixies).
I'm using Symfony and this structure is a default JsonResponse for an array.
Thanks for any advice.
This question has an accepted answers - jump to answer
Answers
http://datatables.net/forums/discussion/12899/post-test-cases-when-asking-for-help-please-read#latest
I found the problem. It couldn't parse returned JSON because the data section contains object instead of nested arrays.
But another problem occurs, because the table isn't refreshing itself by the AJAX.
My config of the datatable:
$('#requirement_list').dataTable({
"processing": true,
"serverSide": true, "sAjaxSource":"'.$view['router']->generate('ajax_get_additional_rows').'",
"sDom": '<"top"lpf>rt<"bottom"><"clear">'
,"aoColumns": [
{ "sType": "natural" },
null,
null,
null,
null,
null,
null,
null,
null
],
"aLengthMenu": [[3, 5, 10, 20,50], [3, 5, 10,20, 50]],
"aaSorting": [[ 0, "desc" ]]
});
I have the natural sort extension implemented.
This does only the initial refresh of all data with no parameters. I've checked that on the examples page even the initial load sends more data,
http://www.datatables.net/examples/data_sources/server_side.html
I get only the request with timestamp parametr.
GET http:// ... route ... /?_=1402894127481
But on the examples it's using the "ajax" settings parametr instead of my "sAjaxSource". Is it correct, these settings?
And there is no way how I can get you the access to the live data or provided them - to replay to the content of provided link.
Thank you for any advice.
Objects will work just fine in DataTables - see the data source manual page.
Are you using
ajax.reload()
to reload the data?Don't use both
ajax
andsAjaxSource
in the same table. The newajax
option replaces the oldsAjaxSource
option and adds a lot of additional functionality.sAjaxSource
is only present for backwards compatibility - hence why it is not in the main documentation.Allan
Hi,
thanks for advice. I was using older version 1.9.4, the examples are for version 1.10.x
Now the datable is sending all GET parameters that I was missing in the request.
Thanks for help