DataTables warning ... Requested unknown parameter

DataTables warning ... Requested unknown parameter

azka2010azka2010 Posts: 2Questions: 0Answers: 0
edited June 2011 in DataTables 1.8
Hello,

datatable alert me with this message, every time i reload the webpage or go to next page (table paging).

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

and i don't think there's something wrong with the table result. the table still load all data from server completely.

should i just ignore this warning or what ?

Thanks,
Regards,
Azkadina
«13

Replies

  • azka2010azka2010 Posts: 2Questions: 0Answers: 0
    Ah, find it myself ... header table has more column than the data itself ...
  • diana888diana888 Posts: 1Questions: 0Answers: 0
    edited June 2011
    I have a same problem: the error message is: DataTables warning: requested unknown parameter '0' from the data source for row 0. No idea.

    Thanks a lot if someone give any clue.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    This message means that DataTables is looking at your data source for array position 0 and not finding it. Why that is depends on your usage of DataTables. You'll need to post your JSON data and your DataTables initialisation code - or even easier a link.

    Allan
  • goodideadavegoodideadave Posts: 12Questions: 2Answers: 0
    I'm developing on an intranet, and have been getting the same message as diana888 as well as the footer says, "showing 1 to 1 of NaN entries (filtered from NaN total entries)". The JSON data looks like this:
    [code]
    {
    "aaData": [
    {
    "UserID": 671,
    "DeleteColumn": "1377",
    "EditColumn": "1377",
    "ExplicitPermissions_UserReportRoleID": 0,
    "ReportNameColumn": "ProviderTrend",
    "ReportRoleColumn": "Impersonate",
    "ImpersonateColumn": true,
    "ProviderID": 0,
    "UserName": "Cramer, Katherine",
    "ExplicitPermissionCount": "1",
    "DenyColumn": false,
    "CommentsColumn": "Test record",
    "ImpersonateMedicalGroupProviderID": "1-503",
    "ImpersonateProviderName": "ABATE MD,LORRAINE E"
    }
    ]
    }
    [/code]
    The datatable definition looks like this:
    [code]
    $('#UserReportRole').dataTable({
    "bProcessing": true,
    "bServerSide": true,

    "sAjaxSource": TargetUrl,
    "sAjaxDataProp": "aaData",
    "sScrollX": '100%',
    //"sScrollXInner": "1000px",
    "bScrollCollapse": true,
    "bAutoWidth": false,
    "sScrollY": "440px",
    "bProcessing": true,
    "bPaginate": false,
    "bDestroy": true,
    "aoColumns": [
    { /* UserID */"sWidth": "20px", "fnRender": function(obj) {
    var str = obj.aData.UserID.toString();
    return str;
    }, "bUseRendered": false
    },
    { /*DeleteColumn*/"sWidth": "56px", "fnRender": function(obj) {
    var str = 'Delete';
    return str;
    }, "bUseRendered": false
    },
    { /* EditColumn */"sWidth": "56px", "fnRender": function(obj) {
    var ar = [];
    ar[ar.length] = "
  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    I think your server-side script is not outputting the expected values in JSON. here's a sample of my JSON

    [code]
    {"sEcho":2,"iTotalRecords":"24467","iTotalDisplayRecords":"24467",aaData: [[...],[...]]}

    [/code]

    this is where the number of records is specified (and without it you're getting NaN) and also in my case aaData is an array of arrays (set of rows). Your JSON looks like an array of objects.

    so.. what's your server-side script look like?
  • goodideadavegoodideadave Posts: 12Questions: 2Answers: 0
    My server-side script is an ASP.NET generic handler. My JSON is indeed an array of objects; I thought that was kosher. I create a generic List of objects and use the Newton-King dll to serialize it:
    [code]
    _jsonReturn = JsonConvert.SerializeObject(items);
    _jsonReturn = "{\"aaData\":" + _jsonReturn + "}";
    [/code]

    It will show the data in the table, and the data passes JSON lint OK.
  • goodideadavegoodideadave Posts: 12Questions: 2Answers: 0
    Found my problem.

    Switched to using aoColumnDefs instead of aoColumns, which helped me figure out that the order of name-value pairs in the JSON was off.
  • goodideadavegoodideadave Posts: 12Questions: 2Answers: 0
    Whoops, not so fast. The footer now shows "Showing 1 to 640 of NaN entries (filtered from NaN total entries)". What's that all about?
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    That bit is almost certainly due to the return not including the JSON bits of information that DataTables needs. The parameters required are defined here: http://datatables.net/usage/server-side , and end up looking something like what fbas posted.

    Allan
  • goodideadavegoodideadave Posts: 12Questions: 2Answers: 0
    Yep, that was it. Thanks, all.
  • mathiasmathias Posts: 12Questions: 0Answers: 0
    edited August 2011
    I have the same problem.

    [quote]allan said:

    This message means that DataTables is looking at your data source for array position 0 and not finding it. [/quote]

    The message means wrong, as it displays the data in my data source correctly, ergo DataTables was able to find everything.

    This is how I set it up:
    the table:
    [code]




    Contact person
    Title
    Website
    Description
    B2B
    B2C




    <?php foreach ($services as $service): ?>


    <?php echo Doctrine_Core::getTable('employee')->find($service->getContactPerson()); ?>
    <?php echo $service->getTitle() ?>
    <?php echo $service->getWebsite() ?>
    <?php echo $service->getDescription() ?>
    <?php echo $service->getB2b() ?>
    <?php echo $service->getB2c() ?>

    <?php endforeach; ?>


    [/code]

    the form:
    [code]




    <?php echo $form->renderHiddenFields(false) ?>
     Back to list
    <?php if (!$form->getObject()->isNew()): ?>
     <?php echo link_to('Delete', 'service/delete?id='.$form->getObject()->getId(), array('method' => 'delete', 'confirm' => 'Are you sure?')) ?>
    <?php endif; ?>





    <?php echo $form->renderGlobalErrors() ?>


    <?php echo $form['contactPerson']->renderLabel() ?>

    <?php echo $form['contactPerson']->renderError() ?>
    <?php echo $form['contactPerson']->render(array('rel'=>'0' )) ?>



    <?php echo $form['title']->renderLabel() ?>

    <?php echo $form['title']->renderError() ?>
    <?php echo $form['title']->render(array('rel'=>'1' )) ?>



    <?php echo $form['website']->renderLabel() ?>

    <?php echo $form['website']->renderError() ?>
    <?php echo $form['website']->render(array('rel'=>'2' )) ?>



    <?php echo $form['description']->renderLabel() ?>

    <?php echo $form['description']->renderError() ?>
    <?php echo $form['description']->render(array('rel'=>'3' )) ?>



    <?php echo $form['b2b']->renderLabel() ?>

    <?php echo $form['b2b']->renderError() ?>
    <?php echo $form['b2b']->render(array('rel'=>'4','value'=>'1' )) ?>



    <?php echo $form['b2c']->renderLabel() ?>

    <?php echo $form['b2c']->renderError() ?>
    <?php echo $form['b2c']->render(array('rel'=>'5','value'=>'1' )) ?>





    [/code]

    the action:
    [code]
    public function executeAdd(sfWebRequest $request)
    {
    $service = new service();
    $service->setContactPerson($_REQUEST['service']['contactPerson']);
    $service->setTitle($_REQUEST['service']['title']);
    $service->setWebsite($_REQUEST['service']['website']);
    $service->setDescription($_REQUEST['service']['description']);
    $service->setOrganization(sfContext::getInstance()->getUser()->getGuardUser()->getOrganization());
    $service->setB2b($_REQUEST['service']['b2b']);
    $service->setB2c($_REQUEST['service']['b2c']);
    $service->save();

    $this->id = $service->getId();
    }
    [/code]
    the template that returns $id:
    [code]
    <?php

    echo $id;

    ?>
    [/code]

    any idea?
  • mathiasmathias Posts: 12Questions: 0Answers: 0
    the rows that are making trouble are b2b and b2c. in the form they are both checkboxes. if i change them to text input, warning is gone. why would checkboxes make trouble?
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    No idea I'm afraid - did you run your page through the W3C validator? A link would help :-)

    Allan
  • mathiasmathias Posts: 12Questions: 0Answers: 0
    edited August 2011
    Two posts ago I wrote something wrong:
    [quote]The message means wrong, as it displays the data in my data source correctly, ergo DataTables was able to find everything.[/quote]
    I didn't look careful enough. The row gets added, but the trouble columns are empty until I refresh. So the message is right.

    [quote]No idea I'm afraid - did you run your page through the W3C validator? A link would help :-)[/quote]
    Thank you. Good idea, I'm doing that just now, 31 Errors, 2 warning(s).

    Am I right in assuming that with DataTabels editable checkboxes work the same way like any other form element? Or is there something I have to adhere to?
  • mathiasmathias Posts: 12Questions: 0Answers: 0
    this is how the form gets rendered in html:
    [quote]




     Back to list







    ContactPerson


    Hans Meiser (Hans Meiser)



    Title




    Website




    Description




    B2b




    B2c






    [/quote]
  • mathiasmathias Posts: 12Questions: 0Answers: 0
    I've read that jEditable doesn't support checkboxes by default. But jEditable is not involved in adding records, only in in updating, isn't it?
  • mathiasmathias Posts: 12Questions: 0Answers: 0
    [quote]mathias said: Am I right in assuming that with DataTabels editable checkboxes work the same way like any other form element? Or is there something I have to adhere to?[/quote]

    ha, that assumption was wrong. author of database-editable doesn't seem to like checkboxes.

    to make it work you have to edit jquery.dataTables.editable.js on line 283 add
    [code]input:checkbox[rel][/code]
  • mathiasmathias Posts: 12Questions: 0Answers: 0
    edited August 2011
    hmmm, but now it always returns value=1 no mather the actual valua, until I refresh.

    EDIT: Lol, I'm dumb.
    [code]
    else if ( ( this.nodeName.toLowerCase() == "input" && this.type=="checkbox" ) || (this.tagName.toLowerCase() == "input" && this.type=="checkbox"))
    if (this.checked)
    {sCellValue = '1';}
    else {sCellValue = '';}
    else
    [/code]
  • smader12smader12 Posts: 1Questions: 0Answers: 0
    edited September 2011
    I think you could have this issue for a number of reasons...just in case anyone else needs a quick work-around because their JSF data table renders a row with one cell when there's no data (e.g. ), I used this JS to get around it (you'd have to use your own variable names/element ID's/etc. of course):

    [code]
    function doMyPageReady()
    {
    x = document.getElementById("SourcingForm:parts"); // The table
    if ( x && x.tBodies && x.tBodies.length>0 )
    {
    // This works for me, but you're match criteria may vary
    if ( x.tBodies[0].innerHTML.length==20 && x.tBodies[0].rows.length ==1 )
    {
    x.tBodies[0].deleteRow(0);
    }
    }
    oTable = jQuery("#SourcingForm\\:parts").dataTable({
    "sScrollY": "200px",
    "bScrollInfinite": true,
    "iDisplayLength" : -1
    });
    .
    .
    .
    [/code]
  • dvnandoverdvnandover Posts: 42Questions: 0Answers: 0
    For me the same error message but some of my column the data value are null. So using if/else statement to assign a empty value when the column data is null would fix it for me.
  • pandutatikondapandutatikonda Posts: 2Questions: 0Answers: 0
    edited September 2011
    Hello,

    Data is not setting to the table?

    [code] function getRows(){
    xyzManager.getRows(... , function(data){
    //how to set this response data to the table.
    dataTable.fnAddData(data);
    })
    }

    dataTable = jQuery("#list").dataTable({
    "bJQueryUI": true,
    "bAutoWidth":false,
    "sPaginationType":"full_numbers",
    "bProcessing":true,
    "bPaginate":true,
    "fnServerData":getRows(),
    "aoColumns": getColumns()
    });
    [/code]
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Try:

    [code]
    "fnServerData":getRows,
    [/code]

    so passing the function, rather than the result of the function.

    Allan
  • pandutatikondapandutatikonda Posts: 2Questions: 0Answers: 0
    Hi allan,

    Thanks for reply. It is fixed. Problem in JSON format.
  • heriquetheriquet Posts: 4Questions: 0Answers: 0
    Hi,

    I also got this error...

    I was declaring a variable inside an "if" and used the variable in my fnAddData(). But the code were not inside the if.

    So when dnAddData was called, I had the error.

    => when using an uninitialized variable, you got also the error.

    Maybe this case should be managed by the plugin to tell that the parameter passed was not declared ? 'don't knof if it's possible...

    Hope this helps! Thank you for this wonderfull plugin!

    [code]

    The initialization :

    if(relation.origin == null)
    {

    var delRel = "Delete relation";
    }

    The fnAddData :

    $('#tableRelations').dataTable().fnAddData( [
    delRel,
    radioB,
    linkRel,
    cdQual,
    "pa",
    "lieu",
    relation.name,
    dt,
    refRel,
    "cdQual"
    ] );


    => if relation.origin is not null, I get the error
    [/code]
  • hackdrackohackdracko Posts: 1Questions: 0Answers: 0
    Este problema se refiere a que la tabla esta mal construida probablemente falta cerrar algun td o tr, o puede que este sobrando alguno de ellos deberian checar bien como esta construida su tabla.
    SALUDOS
  • dvnandoverdvnandover Posts: 42Questions: 0Answers: 0
    Can't seem to be able to get around this error. Here are my aaData:
    "{\"sEcho\":1,\"iTotalRecords\":\"3\",\"iTotalDisplayRecords\":\"3\",\"aaData\":
    [{\"UserName\":\"AAW0\",\"FirstName\":\"John\",\"LastName\":\"Doe\",\"Active\":1},
    {\"UserName\":\"LM945\",\"FirstName\":\"John2\",\"LastName\":\"Doe2\",\"Active\":1},
    {\"UserName\":\"tgm2\",\"FirstName\":\"Jane\",\"LastName\":\"Doe\",\"Active\":1}]}"
    and here is my table initialization:
    function LoadDataTables() {
    //debugger;
    oTable = $("#tblUserList").dataTable({
    "bJQueryUI": true,
    "iDisplayLength": 25,
    "bProcessing": true,
    "bServerSide": true,
    "bDestroy": true,
    "sAjaxSource": "DataBaseTable.ashx?table=IUsers&action=select&usergroup=" + $('#UserGroup').val(),
    "sPaginationType": "full_numbers",
    "aLengthMenu": [[25, 50, 100, -1], [25, 50, 100, "All"]]
    })
    .makeEditable({
    sUpdateURL: "DataBaseTable.ashx?table=IUsers&action=update",
    sUpdateHttpMethod: "POST",
    sAddURL: "DataBaseTable.ashx?table=lUsers&action=new",
    sAddHttpMethod: "POST",
    sDeleteURL: "DataBaseTable.ashx?table=lUsers&action=delete",
    sDeleteHttpMethod: "POST",
    "aoColumns":
    [
    {
    indicator: 'Saving...',
    cancel: 'Cancel',
    submit: 'OK',
    tooltip: 'Click to edit UserName'
    },
    {
    indicator: 'Saving...',
    cancel: 'Cancel',
    submit: 'OK',
    tooltip: 'Click to edit First Name'
    },
    {
    indicator: 'Saving...',
    cancel: 'Cancel',
    submit: 'OK',
    tooltip: 'Click to edit Last Name'
    },
    {
    indicator: 'Saving...',
    cancel: 'Cancel',
    submit: 'OK',
    tooltip: 'Click to set User Active/InActive'
    }
    ],
    "aaSorting": [[1, "asc"]],
    oAddNewRowButtonOptions: { label: "Add...",
    icons: { primary: 'ui-icon-plus' }
    },
    oDeleteRowButtonOptions: { label: "Remove",
    icons: { primary: 'ui-icon-trash' }
    },
    oAddNewRowFormOptions: {
    title: 'Add a new User',
    show: "blind",
    hide: "explode",
    modal: true
    },
    sAddDeleteToolbarSelector: ".dataTables_length"
    });
    }
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    @dvnandover: You need to use mDataProp to tell DataTables where to get the data - see this blog post for more details: http://datatables.net/blog/Extended_data_source_options_with_DataTables

    @heriquet: In future I'm going to look at having DataTables use the default content for a cell if the parameter is not available. The difficult point is that generally this warning behaviour is good since in most cases it is an error - but sometimes you actually that that. It might be a new init option to switch modes.

    Allan
  • dvnandoverdvnandover Posts: 42Questions: 0Answers: 0
    edited November 2011
    I got it thank you very much allan.

    Edit: Just found out that tabletools export (clipboard, excel, pdf) with undefined data instead of actual data. Why? Has anyone encounter the same problem?

    Edit: I found this thread: http://datatables.net/forums/discussion/5346/problems-with-1.8-mdataprop-and-tabletools-exporting-csv-excel.../p1
    dp i replaced the line# 1414 of the TableTools.js version 2.0.1 with this line:
    var mTypeData = dt.aoData[dt.aiDisplay[j]]._aData[dt.aoColumns[i].mDataProp];
    and the export worked except the print button which print preview does not show anyrecords for the table eventhough there are 25 record being displayled at that moment.
  • dvnandoverdvnandover Posts: 42Questions: 0Answers: 0
    edited November 2011
    For somereason the default setting of bShowAll set to true in the TablesTool.js file which caused my problem so i set bShowAll = false in the TablesTool initialization for the print button like this:
    {
    "sExtends": "print",
    "bShowAll: false
    }
    Now the print button worked.
  • argentario84argentario84 Posts: 3Questions: 0Answers: 0
    hi all,
    and hi allan, datatable is great :)

    I have a problem.
    I show with datatables the result of xslt trasformation. I have always the because in my xml i have always these values, but it's possible that I haven't tag, so i received the warning "Requested unknown parameter '1' from the data source for row 0".

    The table is not well formed. Is there a way to show the datatable thead and "No results" like tbody in that case??

    Ps. Thanks, and sorry for my poor English
This discussion has been closed.