DataTables warning (table id = '.....'): Requested unknown parameter '0' from the data so

DataTables warning (table id = '.....'): Requested unknown parameter '0' from the data so

MagicMagic Posts: 2Questions: 1Answers: 0
edited June 2014 in Free community support

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

  • MagicMagic Posts: 2Questions: 1Answers: 0

    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.

  • allanallan Posts: 61,452Questions: 1Answers: 10,055 Site admin
    Answer ✓

    It couldn't parse returned JSON because the data section contains object instead of nested arrays.

    Objects will work just fine in DataTables - see the data source manual page.

    the table isn't refreshing itself by the AJAX.

    Are you using ajax.reload() to reload the data?

    But on the examples it's using the "ajax" settings parametr instead of my "sAjaxSource". Is it correct, these settings?

    Don't use both ajax and sAjaxSource in the same table. The new ajax option replaces the old sAjaxSource 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

  • MagicMagic Posts: 2Questions: 1Answers: 0

    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

This discussion has been closed.