Warning (table id = 'example'): Requested unknown parameter '0' from the data source for row 10

Warning (table id = 'example'): Requested unknown parameter '0' from the data source for row 10

PeteBPeteB Posts: 38Questions: 0Answers: 0
edited March 2012 in General
Hi all,
my first attempt at DataTables and perhaps I've jumped in at the deep-end too soon...

I've gotten my table to successfully get the data from a MySQL database using the server_processing.php template and now I'm trying to implement a CRUD version using jeditable.js.

My problem is that when I execute the adddata.php, the data is successfully added but I get the warning: "DataTables warning (table id = 'example'): Requested unknown parameter '0' from the data source for row 10"

If I increase the display to 25 rows then this warning is for row 25.

I've tried following all the recommendations from previous posts but don't seem to be getting anywhere, please help!

I've saved my Debugger output: here: http://debug.datatables.net/iroyis

I'll add a couple of posts showing the webpage etc.

Replies

  • PeteBPeteB Posts: 38Questions: 0Answers: 0
    My webpage:
    [code]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">


    <?php
    $title='Dings Database Admin - View Players';
    include('adm_inc_lnktitle.php');
    ?>





    <?php include('adm_inc_header.php'); ?>
    <?php include('adm_inc_navigation.php'); ?>




    Last name





    First name





    Date of birth





    Available?





    Year got Cap









    Players Table




    ID
    Last Name
    First Name
    Date Of Birth
    Available?
    Got Cap




















    <?php include('adm_inc_footer.php'); ?>



    $(document).ready(function() {
    $('#example').dataTable({
    "bProcessing": true,
    "sPaginationType": "full_numbers",
    "bJQueryUI": true,
    "bServerSide": true,
    "bJQueryUI": true,
    "sAjaxSource": "scripts/DingsServer_processing.php",
    "aoColumns":[
    {
    "bVisible" : false
    }, //playerID is hidden
    {sName: "lastnme"
    },//lastnme
    {sName: "firstnme"
    },//firstnme
    {sName: "dob"
    },//dob
    {sName: "avail"
    },//avail
    {sName: "gotcap"
    }//gotcap
    ]
    }).makeEditable({
    sUpdateURL: 'scripts/DingsEditable_ajax.php',
    sAddURL: "adm_player_add.php",
    sDeleteURL: "adm_player_delete.php",
    fnOnDeleted: function() {
    oTable.fnReloadAjax(true)
    },
    aoColumns: [
    {
    },
    {
    },
    {
    cssclass: "date"
    },
    {
    type: 'select',
    onblur: 'submit',
    data: "{'':'Please select...', 'Y':'Y','N':'N'}"
    },
    {
    oValidationOptions : { rules:{ value: {minlength: 4 } },
    messages: { value: {minlength: "Enter at least 4 digits"} } }
    }
    ]
    });
    } );




    [/code]
  • PeteBPeteB Posts: 38Questions: 0Answers: 0
    My adddata.php code:
    [code] <?php
    //adm_player_add.php
    // $id = $_REQUEST['id'] ;
    $id = 0;
    $firstname = $_REQUEST['firstname'];
    $lastname = $_REQUEST['lastname'];
    $dob = $_REQUEST['dob'];
    $avail = $_REQUEST['avail'];
    $gotcap = $_REQUEST['gotcap'];

    // connect to the database
    include('conn.php');

    // save the data to the database
    mysql_query("INSERT $app_players SET firstnme='$firstname', lastnme='$lastname', dob='$dob', avail='$avail', gotcap='$gotcap'")
    or die(mysql_error());

    $id = mysql_insert_id();

    echo $id;

    ?>
    [/code]
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    Thanks for including the debug output - although I'm afraid it doesn't really help much in this case as it doesn't integrate with the editable plug-in for DataTables it is looks like the error is from that plug-in or the use of it (I'm not particularly well versed in the plug-in so I'm afraid I'm not sure how much help I will be).

    What I would suggest is to modify the editable plug-in to add a console.log of the data that it is trying to add just before fnAddData (actually, given that you are using server-side processing, using fnAddData is completely pointless in this case, it should just skip that and draw the table - you could perhaps modify the source to do that - just call fnDraw() rather than fnAddData...)

    Allan
  • PeteBPeteB Posts: 38Questions: 0Answers: 0
    Thanks, for the quick response. I'll look into it (I'm a bit of a newbie and so it might take a while!).

    Pete.
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    Okay thanks - pinged you a PM btw :-)

    Allan
  • kaushikTDkaushikTD Posts: 1Questions: 0Answers: 0
    Hey,

    I had this same issue. Calling fnDraw instead of fnAddData solved the issue :). Thank you allan! If you guys had a bigger discussion on this issue, can you include me on that?

    Thank you!

    Kaushik
This discussion has been closed.