Requested unknown parameter '0' from the data source for row 0

Requested unknown parameter '0' from the data source for row 0

ahmed_browserstackahmed_browserstack Posts: 1Questions: 0Answers: 0
edited April 2014 in General
The minimal code for the ajax loading of rows is as below.

[code]
$table
.dataTable({
"bServerSide": true,
"sAjaxSource": "/deals/deal_data",
fnRowCallback: function(tr, data){
var $html = $(data.html_row);
var $tr = $(tr);
$tr.html($html.html());
}
});
[/code]

Data returned from server in the following format.
[code]
{
aaData: [
{
html_row: 'hellocells'
}
]
}
[/code]

Now I understand why data-table is giving this alert error. As you see I am custom populating the cells.
How can I stop datatable from raising the alert 'Requested unknown parameter '0' from the data source for row 0'.?

Replies

  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin
    That's not a data format that DataTables will accept. The preferred return would be something like:

    [code]
    {
    aaData: [
    [ 'hello', 'cells' ]
    ]
    }
    [/code]

    or simile and let DataTables create the HTML.

    I must admit I've never seen data passed to DataTables in that form before, and I don't think there is a way to force it to work.

    Allan
  • ahmed_browserstackahmed_browserstack Posts: 1Questions: 0Answers: 0
    Hi Allan,
    Thanks for the prompt response!
    The reason I am trying to do it that way is because of lot of custom attributes attached to data cells.

    As far as I see Its working, I just need to get rid of the error/alert.

    Or is there a clean way of attaching the attributes to td's?
  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin
    The error is telling you it isn't working :-). DataTables isn't designed for that kind of input - if it does happen to work (I'd be very surprised if every aspect of DataTables works with that) it is completely unintentional and not supported!

    Allan
  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin
    > Or is there a clean way of attaching the attributes to td's?

    Yes, use DT_RowId ( http://next.datatables.net/manual/server-side#Returned-data ) or fnCreatedRow .

    Allan
This discussion has been closed.