Initialisation Error :Requested unknown parameter from the data source for row 0

Initialisation Error :Requested unknown parameter from the data source for row 0

pracede2005pracede2005 Posts: 10Questions: 0Answers: 0
edited September 2012 in General
Hi ,
I am using datatables. I have my datatable initialisation :
[code]
$(document).ready(function() {
oTable = $('#searchList').dataTable( {
"bLengthChange": false,
"sPaginationType": "full_numbers",
"bFilter": false,
"bProcessing": true, // avtive le traitement JSON
//"bServerSide": true,
"sAjaxSource":'/OCC/json/SearchBrochures.action?'+params, // URL d'appel pour recuperer les datas json
"aoColumns": [ // definition de l'ordre et la largeur des colonnes
{ "mData": "libelleCourt","sWidth": "32%" },
{ "mData": "statut","sWidth": "21%" },
{ "mData": "auteur","sWidth": "12%" },
{ "mData": "auteurDerniereModif","sWidth": "7%" },
{ "mData": "dateCloture","sWidth": "7%" },
{ "mData": "dateCreation","sWidth": "21%" }
],
"oLanguage": {
"sProcessing": "Chargement des données en cours...",
"sLengthMenu": "Afficher _MENU_ Enregistrements",
"sZeroRecords": "Aucun élément à afficher",
"sInfo": " _END_ enregistrements sur _TOTAL_",
"sInfoEmpty": "Page 0 de 0 sur 0 entries",
"sInfoFiltered": "(filtrer sur _MAX_ total enregistrements)",
"sInfoPostFix": "",
"sSearch": "Recherche:",
"oPaginate": {
"sFirst": "Premier",
"sPrevious": "Precedent",
"sNext": "Suivant",
"sLast": "Dernier"
}
}
} );
} );
[/code]
Here is the data sent par Ajax Source. I use to Json lint tool to check json syntax :
[code]
{"aaData":[["ARCELOR-2012","Nicolas Coincoin","Nicolas Coincoin","2012-08-06T00:00:00","2012-08-06T00:00:00",1],["ARCELOR-2012","Davy Henry","Davy Henry","2012-08-05T00:00:00","2012-08-05T00:00:00",2],["SNCF-2012","Sylvain Alpha","Sylvain Alpha","2012-08-07T00:00:00","2012-08-07T00:00:00",3],["SNCF-2012","Davy Henry","Davy Henry","2012-08-07T00:00:00","2012-08-07T00:00:00",5]]}
[/code]

But i am getting the following error at initialisation :
[code]DataTables warning (table id = 'searchList'): Requested unknown parameter 'libelleCourt' from the data source for row 0[/code]
What is wrong with my data ?

Replies

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    You don't have a 'libelleCourt' parameter in your data source. You've got an array of arrays, not an array of objects. Have a look through this blog post to read about the difference: http://datatables.net/blog/Extended_data_source_options_with_DataTables

    Allan
  • pracede2005pracede2005 Posts: 10Questions: 0Answers: 0
    Thank you Allan for your response and the link. I am reading ckecking how to send back Array of Object instead of Array of Array.
  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    How to do that will depend upon your server-side environment. It is up to it to create the JSON response, so however you create JSON objects in it would be the way to go. Rubbish answer I know, but I don't know what server-side environment you are using.

    Allan
This discussion has been closed.