DataTables warning ... Requested unknown parameter - Page 3

DataTables warning ... Requested unknown parameter

13»

Replies

  • allanallan Posts: 61,322Questions: 1Answers: 10,023 Site admin
    @josys64 - You've only got two items in the array being returned. DataTables is asking for item three from it (you've for 6 columns) and thus you get the error.

    Allan
  • josys64josys64 Posts: 4Questions: 0Answers: 0
    Thanks Allan
  • flytoastoriaflytoastoria Posts: 1Questions: 0Answers: 0
    i got this type error too :(

    debug link
    [code] http://debug.datatables.net/ikuzoz [/code]


    [code]

    $(document).ready(function(){
    $('#example').dataTable({
    "bRetrieve":true,
    "bJQueryUI":true,
    "sPaginationType" : "full_numbers"
    });
    });

    [/code]
    [code]


    ID User
    Username
    Nama
    Alamat
    No HP
    Level
    Action


    <?php
    while ($data = mysql_fetch_array ($query))
    {
    echo "
    $data[id_user]
    $data[username]
    $data[nama]
    $data[alamat]
    $data[no_hp]
    $data[level]

    EDIT
    |
    Delete

    ";

    }
    ?>


    [/code]

    please help me
  • allanallan Posts: 61,322Questions: 1Answers: 10,023 Site admin
    Your HTML is invalid. There is not TR element in the header.

    Allan
  • patilpatil Posts: 1Questions: 0Answers: 0
    edited October 2013
    Hi I am facing an issue while adding new row in the table...
    Below is my code



    First Column
    Second Column
    Third
    Action






    oTable = $('#table').dataTable({
    "bServerSide": false,
    "bProcessing": true,
    "sAjaxSource": "@Url.Action("Test", "controller")",
    "bDestroy": true,
    "aoColumns": [
    { "mDataProp": "FirstColumn" },
    { "mDataProp": "SecondColumn" },
    { "mDataProp": "ThirdColumn" },
    {
    "mData": null,
    "bSearchable": false,
    "sWidth": '250px',
    "bSortable": false,
    "fnRender": function(oObj) {
    return 'Edit;
    },
    "mDataProp": null
    }
    ]
    });

    Now while adding new row... am facing the below error
    "DataTables warning(table id ='table'): Requested unknown parameter 'FirstColumn' from the data source for row 0"...

    Please help me...
  • allanallan Posts: 61,322Questions: 1Answers: 10,023 Site admin
    As with every other post - link to a test case please.
  • achie453achie453 Posts: 2Questions: 0Answers: 0
    [quote] Help me Allan, I've got this warning :
    DataTables warning (table id = 'example'): Requested unknown parameter '1' from the data source for row 0
    [/quote]

    [code]

    @import "../css/demo_page.css";
    @import "../css/demo_table_jui.css";
    @import "../css/jquery-ui-1.8.4.custom.css";
    @import "../css/TableTools_JUI.css";




    $(document).ready( function () {
    $('#example').dataTable( {
    "bJQueryUI": true,
    "sPaginationType": "full_numbers"


    } );
    } );

    [/code]

    [code]



    Perhitungan Seleksi Surat Lamaran Kerja



    No
    Nama Pelamar
    <?php
    $query = mysql_query("SELECT * FROM kriteria");
    while($data = mysql_fetch_assoc($query)){
    ?>
    <?=$data['nmKriteria']?>
    <?php }?>
    Jumlah
    Status



    [/code]
  • achie453achie453 Posts: 2Questions: 0Answers: 0
    [code]




    <?php
    $no=1;
    if($_GET['pilih'] !=''){
    $query = mysql_query("SELECT * FROM pelamar WHERE idPosisi LIKE '%$_GET[pilih]%' ");
    }
    else $query = mysql_query("SELECT * FROM pelamar ");
    while($data = mysql_fetch_assoc($query)){
    echo ''.$no++.'';
    }
    ?>




    <?php
    if($_GET['pilih'] !=''){
    $query = mysql_query("SELECT * FROM pelamar WHERE idPosisi LIKE '%$_GET[pilih]%'");
    }
    else $query = mysql_query("SELECT * FROM pelamar ");
    while($data = mysql_fetch_assoc($query)){
    echo ''.$data['nmPelamar'].'';
    $idPelamar = $data['idPelamar'];
    echo '';
    }
    ?>



    <?php
    if($_GET['pilih'] !=''){
    $q = mysql_query("SELECT * FROM pelamar WHERE idPosisi LIKE '%$_GET[pilih]%'");
    }
    else $q = mysql_query("SELECT * FROM pelamar ");
    while($dd = mysql_fetch_assoc($q)){
    $d = $dd['sertifikat'];
    echo '';
    $qu = mysql_query("SELECT sk.nmSk,(sk.bobotNilai*k.bobotNilai) as nilai
    FROM subkriteria as sk, kriteria as k
    WHERE k.idKriteria=sk.idKriteria");
    while($hasil = mysql_fetch_assoc($qu)){
    $z = $hasil['nmSk'];
    if ($d == $z){
    echo number_format($hasil['nilai'],3,'.','');
    $tesA[] = number_format($hasil['nilai'],3,'.','');
    $a= number_format($hasil['nilai'],3,'.','');
    ?>

    <?php
    }
    }
    echo '';
    }
    ?>



    <?php
    $sex = mysql_query("SELECT * FROM umur LIMIT 1");
    $hil = mysql_fetch_array($sex);

    if($_GET['pilih'] !=''){
    $q = mysql_query("SELECT *,(YEAR(CURDATE())-YEAR(tglLahir)) AS usia FROM pelamar WHERE idPosisi LIKE '%$_GET[pilih]%'");
    }
    else $q = mysql_query("SELECT *,(YEAR(CURDATE())-YEAR(tglLahir)) AS usia FROM pelamar ");
    while($dd = mysql_fetch_assoc($q)){
    $d = $dd['usia'];
    echo '';
    if ($d >=$hil['min'] and $d<=$hil['max'] ){
    $qu = mysql_query("SELECT (sk.bobotNilai*k.bobotNilai) as nilai
    FROM subkriteria as sk, kriteria as k
    WHERE k.idKriteria=sk.idKriteria AND sk.idSk='Usia3'");
    $hasil = mysql_fetch_assoc($qu);
    echo number_format($hasil['nilai'],3,'.','');
    }
    else if ($d >=$hil['max']){
    $qu = mysql_query("SELECT (sk.bobotNilai*k.bobotNilai) as nilai
    FROM subkriteria as sk, kriteria as k
    WHERE k.idKriteria=sk.idKriteria AND sk.idSk='Usia2'");
    $hasil = mysql_fetch_assoc($qu);
    echo number_format($hasil['nilai'],3,'.','');
    }

    else {

    $qu = mysql_query("SELECT (sk.bobotNilai*k.bobotNilai) as nilai
    FROM subkriteria as sk, kriteria as k
    WHERE k.idKriteria=sk.idKriteria AND sk.idSk='Usia1'");
    $hasil = mysql_fetch_assoc($qu);
    echo number_format($hasil['nilai'],3,'.','');
    }
    echo '';
    $tesB[] = number_format($hasil['nilai'],3,'.','');
    $b= number_format($hasil['nilai'],3,'.','');
    ?>

    <?php
    }
    ?>



    <?php
    if($_GET['pilih'] !=''){
    $q = mysql_query("SELECT * FROM pelamar WHERE idPosisi LIKE '%$_GET[pilih]%'");
    }
    else $q = mysql_query("SELECT * FROM pelamar ");
    while($dd = mysql_fetch_assoc($q)){
    $d = $dd['pglmnKerja'];
    echo '';
    $qu = mysql_query("SELECT sk.nmSk,(sk.bobotNilai*k.bobotNilai) as nilai
    FROM subkriteria as sk, kriteria as k
    WHERE k.idKriteria=sk.idKriteria");
    while($hasil = mysql_fetch_assoc($qu)){
    $z = $hasil['nmSk'];
    if ($d == $z){
    echo number_format($hasil['nilai'],3,'.','');
    $tesC[] = number_format($hasil['nilai'],3,'.','');
    $c= number_format($hasil['nilai'],3,'.','');
    ?>

    <?php
    }
    }
    echo '';
    }
    ?>



    <?php
    if($_GET['pilih'] !=''){
    $q = mysql_query("SELECT * FROM pelamar WHERE idPosisi LIKE '%$_GET[pilih]%'");
    }
    else $q = mysql_query("SELECT * FROM pelamar ");
    while($dd = mysql_fetch_assoc($q)){
    $d = $dd['pendidikan'];
    echo '';
    $qu = mysql_query("SELECT sk.nmSk,(sk.bobotNilai*k.bobotNilai) as nilai
    FROM subkriteria as sk, kriteria as k
    WHERE k.idKriteria=sk.idKriteria");
    while($hasil = mysql_fetch_assoc($qu)){
    $z = $hasil['nmSk'];
    if ($d == $z){
    echo number_format($hasil['nilai'],3,'.','');
    $tesD[] = number_format($hasil['nilai'],3,'.','');
    $d= number_format($hasil['nilai'],3,'.','');
    ?>

    <?php
    }
    }
    echo '';
    }
    ?>





    <?php
    $nx = 0;
    $max = 0;
    foreach($tesA as $d) {
    echo '';
    $jumlah = $d+$tesB[$nx]+$tesC[$nx]+$tesD[$nx];
    $baca = number_format($jumlah,'3','.','');
    echo $baca;

    $bc[] = $baca;
    if ($baca > $max){
    $max = $baca;
    }
    echo '';
    $nx++;

    ?>

    <?php
    }
    ?>





    <?php
    foreach($bc as $p) {
    echo '';
    if ($p == $max){
    echo 'wawancara';
    ?>

    <?php
    }else{
    echo 'gagal';
    ?>

    <?php
    }
    echo '';
    }
    ?>











    <?php
    if (isset($_POST['simpan'])) {
    $nx = 0;
    foreach($_POST['idPelamar'] as $d ) {
    if ($bc[$nx] == $max){
    $query="INSERT INTO seleksi (idPelamar, sertifikat,usia,pglmnKerja,pendidikan,jumlah,status) VALUES ('$d', $tesA[$nx],$tesB[$nx],$tesC[$nx],$tesD[$nx],$bc[$nx],'$_POST[w]') ";
    }else{
    $query="INSERT INTO seleksi (idPelamar, sertifikat,usia,pglmnKerja,pendidikan,jumlah,status) VALUES ('$d', $tesA[$nx],$tesB[$nx],$tesC[$nx],$tesD[$nx],$bc[$nx],'$_POST[g]') ";
    }
    $hasil=mysql_query($query);
    if ($hasil) {
    echo "";
    }
    else {
    echo "koneksi gagal";
    }


    $nx++;
    }
    }
    ?>
    [/code]
  • allanallan Posts: 61,322Questions: 1Answers: 10,023 Site admin
    @achie453 - Please link to a test case as noted in the forum rules.
  • SJNRSJNR Posts: 2Questions: 0Answers: 0
    edited April 2014
    I was getting this error : and here is a gotcha to be aware of.

    If you are pipelining data (using the example function given) ,
    and you open a descriptive row using fnOpen() - and leave it open..

    Then try to load new table data - you will get this error.

    You must remember to clear the pipeline cache before the new Load.
    Reset : datatabels_pipeline_Cache={iCacheLower:-1};

    Doh!

    I was even destroying and recreating the DataTable (in preparation for a new dataset)

    Closing the rows prior to the load will help... but it is not the correct solution. (for obvious reasons)

    I would guess... somewhere in the pipeline cache it mis-aligns the data structure as set in aoColumnDefs ( I didn't have the time to investigate, just to find the problem and fix it)

    (sorry Allan :- "Please link to a test case as noted in the forum rules" .... : way way too complicated and the gotcha is easier to explain :-) )
  • allanallan Posts: 61,322Questions: 1Answers: 10,023 Site admin
    Yup - works for me in this case. Explanations don't need a test case. Only questions :-)

    Allan
  • tanzaniangurutanzanianguru Posts: 2Questions: 0Answers: 0
    Hellow, really glad i found this discussion. i am getting a similar error in my DataTables. Though my error is Requested unkown parameter "0" in the row "0". This happens only when my tables have no values at all. Please anyone with the idea of how to fix this.
  • tanzaniangurutanzanianguru Posts: 2Questions: 0Answers: 0
    [code]



    Reg Number
    Tag ID
    Owner
    Phone Number
    Email
    Time
    Location
    Speed
    Actions





    <?php
    $this->load->model('vehicles');
    $data = $this->vehicles->get_follow_ups($this->session->userdata('user_id'));

    foreach( (isset($data)) ? $data : '' as $d):

    $overspeeding = 100;
    $speed = (isset($d['vehicle_speed']))? $d['vehicle_speed'] : '';
    $veh_no = (isset($d['reg_no']))? $d['reg_no'] : '';
    $veh_tag = (isset($d['tag_id']))? $d['tag_id'] : '';
    $ownr = (isset($d['owner']))? $d['owner'] : '';
    $ownr_phn = (isset($d['owners_phone']))? $d['owners_phone'] : '';
    $ownr_email = (isset($d['owners_email']))? $d['owners_email'] : '';
    $veh_time = (isset($d['captured_time']))? $d['captured_time'] : '';
    $veh_loc = (isset($d['vehicle_location']))? $d['vehicle_location'] : '';

    $officer_id = $this->session->userdata('user_id');

    $url = site_url('dashboard/table_actions')."?user_id=".$officer_id."&&regist_no=".$veh_no."&&tag_id=".$veh_tag
    ."&&owner=".$ownr."&&phone=".$ownr_phn."&&email=".$ownr_email."&&time=".$veh_time
    ."&&location=".$veh_loc."&&speed=".$speed."&&page="."overview"."&&action=remove";

    $url2 = site_url('dashboard/table_actions')."?user_id=".$officer_id."&&regist_no=".$veh_no."&&tag_id=".$veh_tag
    ."&&owner=".$ownr."&&phone=".$ownr_phn."&&email=".$ownr_email."&&time=".$veh_time
    ."&&location=".$veh_loc."&&speed=".$speed."&&page="."overview"."&&action=captured";

    $url3 = site_url('dashboard/table_actions')."?user_id=".$officer_id."&&regist_no=".$veh_no."&&tag_id=".$veh_tag
    ."&&owner=".$ownr."&&phone=".$ownr_phn."&&email=".$ownr_email."&&time=".$veh_time
    ."&&location=".$veh_loc."&&speed=".$speed."&&page="."overview"."&&action=search";


    $redback = "";

    if ($overspeeding <= $speed)
    {
    $redback = "";
    }
    echo "".$veh_no."";
    echo "".$veh_tag."";
    echo "".$ownr."";
    echo "".$ownr_phn."";
    echo " ".$ownr_email.""."";
    echo "".$veh_time."";
    echo "".$veh_loc."";
    echo "".$redback.$speed."Km/h".""."";
    echo "
    &nbsp&nbsp

    &nbsp&nbsp

    &nbsp&nbsp


    ";
    echo "";

    endforeach;
    ?>


    [/code]
  • james270212james270212 Posts: 6Questions: 1Answers: 0

    M getting same error <<<datatables warning (table id = 'example') requested unknown parameter>>>

    Can anyone help Me please ???

    Here is My code

    <

    div id="tableDiv" class="body">

    <

    table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="example">
    <thead style="background-color: #E8E8E8;">
    <tr>
    <!-- <th><input type="checkbox" id="toggle-checkboxes" value="option2" /></th> -->
    <th width="10%">User Name</th>
    <th width="20%">Action Name</th>
    <th width="20%">Action Event</th>
    <th width="35%">Action Description</th>
    <th width="10%">Action Time</th>
    <th width="5%">Action Status</th>
    </tr>
    </thead>
    <tbody> </tbody>

    var table = $("#example").dataTable({

                    "bServerSide": true,
                    "bDestroy": true,
                    "sAjaxSource": "${pageContext.request.contextPath}/admin/AdminService?hdnmode=user_audit_trail_data&fromDate="+ $("#input-datetimepicker2").val() +"&toDate="+$("#input-datetime2picker").val(),
                    "bProcessing": true,
                    //"sPaginationType": "full_numbers",
                    "bJQueryUI": true,
                    "sServerMethod": "POST",
    
                    "aoColumns": [
                                  { "mDataProp": "userName" },   
                                  { "mDataProp": "actionName" },
                                  { "mDataProp": "actionEvent" },
                                  { "mDataProp": "actionDescription" },
                                  { "mDataProp": "actionTime" },
                                  { "mDataProp": "actionStatus" }
                              ],
    
                    "aLengthMenu": [
                    [5, 10, 50, 100,500, -1],
                    [5, 10, 50, 100,500, "All"]
                    ],
                    "iDisplayLength" : 5,
    
                });
    
                for (var i=0; i< ParsedObject.length; i++) {
                    var temp_item = ParsedObject[i]; //new row data
                    table.fnAddData(temp_item.userName, temp_item.actionName, temp_item.actionEvent, temp_item.actionDescription, temp_item.actionTime, temp_item.actionStatus); //adds new row to datatable
                }
    
  • james270212james270212 Posts: 6Questions: 1Answers: 0

    M getting same error <<<datatables warning (table id = 'example') requested unknown parameter>>>

    Can anyone help Me please ???

    Here is My code

    <

    div id="tableDiv" class="body">

    <

    table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="example">
    <thead style="background-color: #E8E8E8;">
    <tr>
    <!-- <th><input type="checkbox" id="toggle-checkboxes" value="option2" /></th> -->
    <th width="10%">User Name</th>
    <th width="20%">Action Name</th>
    <th width="20%">Action Event</th>
    <th width="35%">Action Description</th>
    <th width="10%">Action Time</th>
    <th width="5%">Action Status</th>
    </tr>
    </thead>
    <tbody> </tbody>

    var table = $("#example").dataTable({

                    "bServerSide": true,
                    "bDestroy": true,
                    "sAjaxSource": "${pageContext.request.contextPath}/admin/AdminService?hdnmode=user_audit_trail_data&fromDate="+ $("#input-datetimepicker2").val() +"&toDate="+$("#input-datetime2picker").val(),
                    "bProcessing": true,
                    //"sPaginationType": "full_numbers",
                    "bJQueryUI": true,
                    "sServerMethod": "POST",
    
                    "aoColumns": [
                                  { "mDataProp": "userName" },   
                                  { "mDataProp": "actionName" },
                                  { "mDataProp": "actionEvent" },
                                  { "mDataProp": "actionDescription" },
                                  { "mDataProp": "actionTime" },
                                  { "mDataProp": "actionStatus" }
                              ],
    
                    "aLengthMenu": [
                    [5, 10, 50, 100,500, -1],
                    [5, 10, 50, 100,500, "All"]
                    ],
                    "iDisplayLength" : 5,
    
                });
    
                for (var i=0; i< ParsedObject.length; i++) {
                    var temp_item = ParsedObject[i]; //new row data
                    table.fnAddData(temp_item.userName, temp_item.actionName, temp_item.actionEvent, temp_item.actionDescription, temp_item.actionTime, temp_item.actionStatus); //adds new row to datatable
                }
    
  • kirizkiriz Posts: 4Questions: 0Answers: 0
    edited June 2014

    Hi. I get a following error: table id=newsTable - Requested unknown parameter '0' for row 0.
    My code:
    Javascript:

        $('#newsTable').dataTable({
            "bServerSide": true,
            "bProcessing": true,
            "sAjaxSource": '/MainPage/GetAllNews',
                "fnServerData": function(sSource, aoData, fnCallback, oSettings) {
                    oSettings.jqXHR = $.ajax({
                        "dataType": 'json',
                        "type": "POST",
                        "url": sSource,
                        "data": {
                            iDisplayStart: aoData[3].value,
                            iDisplayLength: aoData[4].value
                        },
                        "success": fnCallback,
                        "error": function(data) {
                            er = data;
                        }
                    });
                },
                "aoColumnDefs": [
                    { "sType": "numeric", "sName": "Id", "aTargets": [2] },
                    { "sType": "date", "sName": "Last Modified Date", "aTargets": [4] },
                    { "sType": "string", "sName": "Subject", "aTargets": [6] },
                    { "sType": "date", "sName": "Publish Date", "aTargets": [5] },
                    { "sType": "date", "sName": "Expire Date", "aTargets": [1] },
                    { "sType": "string", "sName": "Author", "aTargets": [0] },
                    { "sType": "string", "sName": "Language", "aTargets": [3] }            ]
            });
    

    HTML:

    <table id="newsTable">
            <thead>
                     <tr>
                         <th></th>
                         <th></th>
                         <th></th>
                         <th></th>
                         <th></th>
                         <th></th>
                         <th></th>
                      </tr>
             </thead>
             <tbody>                                        
             </tbody>
    </table>
    

    I return a 2D array with aaData array of correct data in 7 columns.
    I tried adding this to "aoColumnDefs"

    { sDefaultContent: '', aTargets: ['_all'] }
    

    When I add that the error is not there but there are also no data in the table.

    I don't know what I am doing wrong. Any help would be highly appreciated! Thanks!

  • kirizkiriz Posts: 4Questions: 0Answers: 0

    Correction - I get an array of objects in aaData array. Could that be the problem? Thanks.

  • allanallan Posts: 61,322Questions: 1Answers: 10,023 Site admin

    If you get objects back, you need to tell DataTables. See the data page in the manual.

    Allan

  • kirizkiriz Posts: 4Questions: 0Answers: 0

    Allan thanks for your reply. I solved the issue with

     "aoColumns": [
                { "mData": "Id" }, ... ]
    
This discussion has been closed.