Problem with DataTables and JSON integer
Problem with DataTables and JSON integer
Hi, I have a little (or big, I don't realy know) problem with a DataTable.
I try to get informations from my database. I encode my information with json_encode. All string and Datetype datas are OK, but when I try to get and integer I have this message :_ DataTables warning: table id=example - Requested unknown parameter 'id' for row 0. For more information about this error, please see http://datatables.net/tn/4_
Off course I tried a lot of thing but it still doesn't work...
If you have any idea
This is my table
var table = $('#example').DataTable({
"ajax": "{{ path('example_paginate') }}", //url to the php function which json_encode datas
"sAjaxDataProp": "data",
"columns":[
{"data": "id"},
{"data": "firstname"},
{"data": "lastname"},
{"data": "adress"},
{"data": "creationdate"}
],
"columnDefs": [
{
"targets": [ 0 ],
"type": "num",
"visible": false,
"searchable": false
}
]
});
$('#prospect-list tbody').on('click', 'tr', function () {
var row = table.row(this).data();
console.log(row);
} );
Replies
What is the JSON returned to the client?
Maybe you can provide the Datatables debugger output:
https://datatables.net/manual/tech-notes/10
Seeing the data returned is needed to help troubleshoot.
Kevin
Thank you for that tips!
The JSON returned was :
So my integer "id" just disapair between my php function and DataTable. And I don't know why cause my json_encode return the data with "id". But now I know more precisely where is my problem.