oSettings is null when using server-side

oSettings is null when using server-side

bocodebocode Posts: 9Questions: 0Answers: 0
edited February 2010 in General
Hello All,
I'm using datatables inside a div to show a report based on a form submission. Here's my code:
----

$('#submit3').click(function() {
$('#rresults').hide();
$('#rrtable').dataTable( {
"bProcessing": true,
"bServerSide": true,
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"bAutoWidth": false,
"sAjaxSource": "/cgi-bin/shlk/reports.pl?sdrm="+$('#sdrm').val()+"&edrm="+$('#edrm').val()
});
var tbl =$('#rrtable').dataTable();
tbl.fnDraw();
$('#rresults').show();
});

------
1) so basically user enters info in form fields, hits the submit button.
2) datatable (rrtable) is inside rresults div and am hiding/shwoing that before/after i get the results from backend.
3) so when i hit submit, am getting an error which says "oSettings is null". The request is not sent to the backend also.

what am doing wrong?

Thank you

Ps: Also Allan, if you are reading this, I would like to thank you for a wonder ful piece of software that you created :-).

Replies

  • vexvex Posts: 30Questions: 0Answers: 0
    You're re-declaring DataTables on the table without any options, try this instead:
    [code]$('#submit3').click(function() {
    $('#rresults').hide();
    var tbl = $('#rrtable').dataTable( {
    "bProcessing": true,
    "bServerSide": true,
    "bJQueryUI": true,
    "sPaginationType": "full_numbers",
    "bAutoWidth": false,
    "sAjaxSource": "/cgi-bin/shlk/reports.pl?sdrm="+$('#sdrm').val()+"&edrm="+$('#edrm').val()
    });
    tbl.fnDraw();
    $('#rresults').show();
    });[/code]

    (I just removed "var tbl =$('#rrtable').dataTable();" and saved the reference from the first call in "tbl")
  • micandrmicandr Posts: 4Questions: 0Answers: 0
    I'm facing the same issue. Sometimes datatables stop working and sometimes Safari crash...

    I've set up datatables with some external inputs for filtering: when I try a search (using the external input) the debugger give me this error (but still draw the table).
    TypeError: Result of expression 'oSettings' [null] is not an object. -- jquery.dataTables.js:2631

    Somethins the error becomes this: (and datatables stops working)
    TypeError: Result of expression 'oSettings.aoData[iRow]' [undefined] is not an object. -- jquery.dataTables.js:1521

    I will be really grateful if someone can give me an hint.
    Michele.




    here is the code that I use:

    [code]
    var oTable = $('#tutto').dataTable( {
    "sDom": 'rtipl',
    "oLanguage": { "sUrl": "../include/dataTables-1.6/it_IT.txt" },
    "aoColumns": [ /* id */ { "bVisible": false }, /* priorita */ { "bVisible": false }, /* stato */ { "bVisible": false }, /* num_richiesta */ { "bSortable": false }, /* data_richiesta */ { "bVisible": false }, /* budget */ { "bVisible": false }, /* dipartimento */ { "bVisible": false }, /* unita */ null, /* show_details */ { "bSortable": false }, /* apparecchiatura */ null, /* civab */ { "bVisible": false }, /* quantita */ { "bSortable": false }, /* preventivo */ null, /* note */ { "bVisible": false }, /* consumi */ { "bVisible": false }, /* note_commissione */ { "bVisible": false }, /* classe_commissione */ { "bVisible": false }, /* autorizzazione */ { "bVisible": false }, /* ordine */ { "bSortable": false }, /* data_ordine */ null, /* importo */ null, /* num_fattura */ { "bVisible": false }, /* data_fattura */ { "bVisible": false }, /* data_collaudo */ { "bVisible": false }, /* prot_collaudo */ { "bVisible": false }, /* show_tags */ { "bSortable": false }],
    "sPaginationType": "full_numbers",
    "bProcessing": true,
    "bServerSide": true,
    "sAjaxSource": "./server_processing.php",
    "fnServerData": function ( sSource, aoData, fnCallback ) {
    /* Add some extra data to the sender */
    aoData.push( { "name": "dipartimento_id", "value": $('#dipartimento_id').val() }, { "name": "unita_id", "value": $('#unita_id').val() },
    { "name": "APP", "value": "budget" },
    { "name": "el", "value": "tutto" },
    { "name": "table", "value": 'mainlist' },
    { "name": "show", "value": show },
    { "name": "tag", "value": "" },
    { "name": "search", "value": search } );
    $.getJSON( sSource, aoData, function (json) {
    /* Do whatever additional processing you want on the callback, then tell DataTables */
    fnCallback(json)
    } );
    },
    "fnDrawCallback": function() {

    $('.tooltip', oTable.fnGetNodes()).cluetip({
    showTitle: false,
    cluetipClass: 'jtip',
    arrows: true,
    dropShadow: false
    });

    $('#tutto tbody tr').each( function () {
    var aData = oTable.fnGetData( this );

    if ( 18 != '999' && aData[18] != '') {
    $(this).addClass('gradeA');
    } else
    if ( 2 != '999' && aData[2] == '1') {
    $(this).addClass('gradeU');
    } else
    if (1 != '999' && aData[1] != '') {
    $(this).addClass('pr_'+aData[1]);
    }

    });

    }
    } );
    [/code]
  • micandrmicandr Posts: 4Questions: 0Answers: 0
    Seems it crashes when the results of a search is 0 items.
    Very strange... using the debugger of Safari I've seen that the variable oSettings.oFeatures.bSort is always true... strange that the error is "is not an object".

    Michele.
  • allanallan Posts: 63,510Questions: 1Answers: 10,471 Site admin
    What is the JSON code returned from the server? If you look in Inspector or Firebug you'll be able to see it.

    Allan
  • micandrmicandr Posts: 4Questions: 0Answers: 0
    edited March 2010
    this is one...
    [code]
    {"sEcho": 22, "iTotalRecords": 546, "iTotalDisplayRecords": 7, "aaData": [ ["116","Nuovo Osp.",""," ","Dip Medicina","USC Gastroenterologia","","Argon Plasma Coagulation (APC) (elet ...","ELB","1","30.000","","prezzo indicativo","manipoli dedicati","","","V ADPQ&nbsp"],["559","Nuovo Osp.","559"," ","Direzione Sanitaria","Direzione Medica di Presidio","","elettrobisturi","ELB","24","246.000","","Elettrobisturi di alto/medio livello ...","","","","V ADPQ&nbsp"],["783","Nuovo Osp.","783"," ","Dip Medicina","USSD Pronto Soccorso","","Elettrobisturi","ELB","1","10.000","0","per sala piccoli interventi","","","","Senza Fin.&nbsp"],["815","Nuovo Osp.","815"," ","Dip Materno-Infantile e Pediatrico","USC Chirurgia Pediatrica","","Elettrobisturi","ELB","1","6.000","0","per ambulatorio piccoli interventi","","","","Senza Fin.&nbsp"],["1071","Nuovo Osp.","1071","16/03/2009","Dip Materno-Infantile e Pediatrico","USC Ostetricia e Ginecologia","","Elettrobisturi per sala cesarei","ELB","2","24.000","","","","","","V ADPQ&nbsp"],["1227","Nuovo Osp.","1227","27/05/2009","Dip Cardiovascolare","USC Chirurgia Vascolare","","Elettrobisturi","ELB","1","10.000","","per Ambulatorio

    Manca visto ...","","","","Senza Fin.&nbsp"],["1725","Nuovo Osp.","1725"," ","Dip Cardiovascolare","USC Cardiologia II - Diagnostica Int ...","","elettrobisturi","ELB","1","6.000","","richiesta 28/1/2010","","","","Senza Fin.&nbsp"]] }[/code]

    and this is one the search results is empty (the error that make datatables stop working)

    [code]
    {"sEcho": 23, "iTotalRecords": 546, "iTotalDisplayRecords": 0, "aaData": [] }
    [/code]
  • allanallan Posts: 63,510Questions: 1Answers: 10,471 Site admin
    Curious - I've been tracing a bug in Firefox which sounds similar, but I'd be surprised if it was the same since you are seeing the JSON return in Firebug (I'm not - but it does get to the computer - weird).

    Do you have a link you can post showing an example of this. http://datatables.net/contact if you don't want to make it public.

    Allan
  • micandrmicandr Posts: 4Questions: 0Answers: 0
    It seems that the error is the line used to apply different colors to the elements.

    [code]var aData = oTable.fnGetData( this );[/code]

    When the table is empty... this line make something "bad"

    Michele.
  • allanallan Posts: 63,510Questions: 1Answers: 10,471 Site admin
    When the table is empty, how can you have 'this' being a TR element, since there are no TR elements? What is this in this context - perhaps it is something that DataTables should cope with...

    Allan
This discussion has been closed.