DataTables warning (table id = 'My Table'): Requested unknown parameter '0' from the data source

DataTables warning (table id = 'My Table'): Requested unknown parameter '0' from the data source

gbrokegbroke Posts: 7Questions: 0Answers: 0
edited March 2012 in DataTables 1.9
I know this is a pretty common error, that is generally an issue with the column count. I do have the column column correct, and my javascript array appears to be good. I am stumped.

I used the datatables debugger. Here is my debug info:

http://debug.datatables.net/unefuy

Thank you for any help.

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Brilliant - thanks for the debugger trace!

    You need to use mDataProp to tell DataTables what property you want to use from your data source objects. The objects have no inherent order, so there is no way for DataTables to know what property you want to belong in each column unless you specifically tell it.

    This blog post has more information about mDataProp: http://datatables.net/blog/Extended_data_source_options_with_DataTables

    Allan
  • gbrokegbroke Posts: 7Questions: 0Answers: 0
    Awesome Allan! That worked perfectly. I have used the datatables many times before and never used the 'mDataProp' before. WOW! All my working tables have a column for every field returned, and I would just turn off visibility on the un-needed ones. That was a huge pain when it came to ordering. Now with mDataProp, I see that changes everything. Thank you so much!
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    No problem at all - great to hear that does the job for you :-)

    mDataProp certainly opens up a huge number of options for DataTables - I'm going to write up a blog post soon about using it as a function to allow orthogonal data to be used for sorting / display / filtering etc...

    Allan
  • aalapkaalapk Posts: 4Questions: 0Answers: 0
    Hi Allan,

    I am very new to datatables, but already find it very exciting. I am facing a similar issue - a warning "requested unknown parameter...".
    Here is my debug info:
    http://debug.datatables.net/esakej

    What I am trying to do is to show/hide a particular record of a table, using an example from here: http://datatables.net/release-datatables/examples/api/row_details.html

    From the debugger info, I can see that the 'Type' of the first column (which is dynamically created) is not coming through, and can be the issue. But I can't figure out how to tackle that. Am not sure if I need to use mDataProp here and if so, how. Your help is most appreciated!

    Thanks.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hi,

    Thanks for the debug trace. What I think is causing the problem is that:

    - You have 6 items being returned from the server, per row
    - You have 7 columns in the table

    These two need to match, since DataTables is currently looking for data for the 7th column, but it isn't in the data source! If there is no such data, or you want just a static value for the 7th column, you can use sDefaultContent .

    Allan
  • oitsukioitsuki Posts: 4Questions: 0Answers: 0
    hello,

    I use the latest script, I have the same pb.

    there my code :
    DataTables warning (table id = 'example'): Requested unknown parameter '0' from the data source for row 4



    [code]

    ......

    @import "ext/javascript/DataTables-1.9.1/media/css/demo_page.css";
    @import "ext/javascript/DataTables-1.9.1/media/css/demo_table_jui.css";







    $(document).ready(function() {
    oTable = $('#example').dataTable({
    "bPaginate": false,
    "bLengthChange": false,
    "bFilter": false,
    "bSort": true,
    "bInfo": false,
    "bAutoWidth": false,

    "bJQueryUI": true
    });
    } );


    .......







    <!-- 13 row below -->



     
     
    <?php echo TABLE_HEADING_MODEL; ?>
    <?php echo TABLE_HEADING_PRODUCTS; ?>
    <?php
    if (MODE_B2B_B2C == 'true') {
    ?>
    <?php echo TABLE_HEADING_PRODUCTS_GROUP; ?>
    <?php
    }
    ?>
    <?php echo TABLE_HEADING_PERCENTAGE; ?>
    <?php echo TABLE_HEADING_PRODUCTS_PRICE; ?>
    <?php echo TABLE_HEADING_SCHEDULED_DATE; ?>
    <?php echo TABLE_HEADING_EXPIRES_DATE; ?>
    <?php echo TABLE_HEADING_ARCHIVE; ?>
    <?php echo TABLE_HEADING_STATUS; ?>
    <?php echo TABLE_HEADING_ACTION; ?> 


    <?php

    ......


    while ($specials = tep_db_fetch_array($specials_query)) {
    ?>

    <!-- 13 row below -->





    <?php
    if (MODE_B2B_B2C == 'true') {
    ?>

    <?php
    }
    ?>











    <?php
    } // end while
    ?>
    [/code]

    if I insert a new row ( ===> 14 row) in the while condition, The error deseapear. i don't understand i need insert a new row in the while condition.
    head of the table : 13 row
    data inside the table : 14 row


    Thanks
  • oitsukioitsuki Posts: 4Questions: 0Answers: 0
    To complete th post above :

    if I insert this in the while condition
    [code]
    dfgdfg
    dfg
    dgfd
    dfgdfg
    dfgdfg
    dfgdfg
    dgdfgdfg
    dgfdg
    dfgdfg
    dfgdfg
    dgfdg
    dgdfgdf
    [/code]

    it work perfect but If I do that

    [code]


    <?php
    if ($specials['selected']) {
    ?>

    <?php
    } else {
    ?>

    <?php
    }
    ?>

    dfgdfg
    dfg
    dgfd
    dfgdfg
    dfgdfg
    dfgdfg
    dgdfgdfg
    dgfdg
    dfgdfg
    dfgdfg
    dgfdg
    dgdfgdf

    [/code]

    the error appear : why ?
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    [quote]
    head of the table : 13 row
    data inside the table : 14 row
    [/quote]

    That's the problem - they must match exactly, or you will get this error.

    In your second post above you are adding an extra column - you've got an if condition around the input element which is fine - but there is still one extra column there.

    Allan
  • oitsukioitsuki Posts: 4Questions: 0Answers: 0
    In fact I found the error : the problem come of the checkbox

    [code]
    <?php
    if ($specials['selected']) {
    ?>

    <?php
    } else {
    ?>

    <?php
    }
    ?>
    [/code]

    The error : DataTables warning (table id = 'example'): Requested unknown parameter '0' from the data source for row 4


    If i change by that, the error deseapear
    [code]hlkhjkl [/code]

    How to resolve that
  • rkumarrkumar Posts: 5Questions: 0Answers: 0
    I am having the same problem - "DataTables warning (table id = 'roles_list'): Requested unknown parameter '0' from the data source for row 0". I have provided the link to the data tables debugged output - " http://debug.datatables.net/elozap ". I can see the properly formatted JSON output in firebug but I am unable to get the table to display the data. Please guide.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    > "sAjaxSource": null,

    If you aren't Ajax loading data, don't include sAjaxSource at all. Also DataTables isn't doing the Ajax there - so I'm not sure what is. You'd need to give us a link - see: http://datatables.net/forums/discussion/12899/post-test-cases-when-asking-for-help-please-read

    Allan
  • snapstevesnapsteve Posts: 1Questions: 0Answers: 0
    I had a similar problem when I upgraded from 1.9.1 to 1.9.4 today. The last column on one of my tables is a button (has no json field). It worked previous but today I started to get the "Requested unknown parameter..." error.

    [code]
    {
    "mDataProp": null,
    "bSortable": false,
    "bSearchable": false,
    "sWidth": "15px"
    }
    [/code]

    I solved it by changing 'mDataProp' to 'mData' - maybe something in the handling of the deprecation is funky when it comes to null values?

    Hopefully that helps.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    edited January 2013
    > maybe something in the handling of the deprecation is funky when it comes to null values?

    Correct :-(. It has been fixed in git, but 1.9.4 does indeed suffer from a bug there.

    Allan
This discussion has been closed.