Server side - mData - unknown parameter

Server side - mData - unknown parameter

partyboypartyboy Posts: 18Questions: 0Answers: 0
edited February 2013 in General
Hi,

I know that this is a common error an the subject has been already discussed but I still can't get it worked :)

Here is my datatable initialisation :

[code]
rfTable = $('.data-table').dataTable( {
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"aoColumns": [
{ "mData": "dateCreated" },
{ "mData": "name" },
{ "mData": "email"},
],
"bProcessing": true,
"bServerSide": true,
"bPaginate":true,
"fnServerData": fnDataTablesPipeline,
"sAjaxSource": "/datatableAjax",

} );
[/code]

Here is my oaData Return

[code]
{"email":"test","name":"test","dateCreated":"test"}
[/code]

I'm getting this error :

DataTables warning (table id = 'DataTables_Table_0'): Requested unknown parameter 'dateCreated' from the data source for row 0

Where is my problem ? does the datas in my oadData must ben in the same order that the declaration of the mData ?

Thanks

Replies

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    > Requested unknown parameter 'dateCreated' from the data source for row 0

    There is no `dateCreated` property in your data source objects. Please link to a test case or run the table through the debugger so we can help further.

    Allan
  • partyboypartyboy Posts: 18Questions: 0Answers: 0
    Hi Allan, thanks for you're quick responses, here is the link for the debugger :

    http://debug.datatables.net/adutub
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Unfortunately because you are overriding fnServerData I can't see what data is being returned form the server. Can you remove your override for fnServerData and run the debugger again.

    Allan
  • partyboypartyboy Posts: 18Questions: 0Answers: 0
    here is the updated version with no override : http://debug.datatables.net/aruzug

    thanks for your time
  • partyboypartyboy Posts: 18Questions: 0Answers: 0
    I'm checking the debugger, in the TABLE tab, I'm looking at the different rows. I see the data that I send and in the end : the 3 columns name with null values. It looks weird :)
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    The trace in `aruzug` shows that you are still setting fnServerData so I can't see what data is returned still. To make a POST request use sServerMethod rather than overriding fnServerData .

    Allan
  • partyboypartyboy Posts: 18Questions: 0Answers: 0
    My mistake, sorry. Here the (I hope) correct link : http://debug.datatables.net/ujarox

    I'm getting a new error that leads to a problem in my side :

    DataTables warning (table id = 'DataTables_Table_0'): DataTables warning: JSON data from server could not be parsed. This is caused by a JSON formatting error.
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Thanks for that.

    So the error is being caused by the browser trying to load HTML from your Ajax request. Which suggests to me that there is a 404 error / the sAjaxSource parameter is wrong.

    To see what is returned, click on the 'Tables' button in the debugger and then pick the 'Server interaction' tab.

    Allan
  • partyboypartyboy Posts: 18Questions: 0Answers: 0
    In fact when I use the default fnServerData, I get this error : Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported

    There is a way to tell that is json ? When using my overrided method I set dataType to 'json' and there was no error.

    thanks
  • partyboypartyboy Posts: 18Questions: 0Answers: 0
    I think this is because my data's need to be stringified before being sent. but with the default fnServerData how can I do that ?

    Here is my actual configuration :

    [code]
    rfTable = $('.data-table').dataTable( {
    "bJQueryUI": true,
    "sPaginationType": "full_numbers",
    "aoColumns": [
    { "mData": "dateCreated" },
    { "mData": "name", sDefaultContent: "" },
    { "mData": "email", sDefaultContent: "" },

    ],
    "bProcessing": true,
    "bServerSide": true,

    "bPaginate":true,
    //"fnServerData": fnDataTablesPipeline,
    "sAjaxSource": "/userManagement/admin/search2",
    "sServerMethod": "POST"
    // "sDom": '<""l>t<"F"fp>',
    // "fnServerData": function ( sSource, aoData, fnCallback ) {
    // $.ajax( {
    // dataType: 'json',
    // contentType: "application/json;charset=UTF-8",
    // type: 'POST',
    // url: sSource,
    // data: stringify_aoData(aoData),
    // success: fnCallback,
    // error : function (e) {
    // //alert (e.responseText);
    // alert('erreur');
    // }
    // } );
    // }
    } );
    [/code]

    You can see in my commented code, before I was doing : data: stringify_aoData(aoData)
  • partyboypartyboy Posts: 18Questions: 0Answers: 0
    It's me again :) It's working ! I was doing a wrong parsing in the server, I fixed that and now it's ok.

    Thanks for you're time, It helps me a lot !
This discussion has been closed.