oSettings is null when using server-side
oSettings is null when using server-side
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 :-).
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 :-).
This discussion has been closed.
Replies
[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")
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]
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.
Allan
[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 "],["559","Nuovo Osp.","559"," ","Direzione Sanitaria","Direzione Medica di Presidio","","elettrobisturi","ELB","24","246.000","","Elettrobisturi di alto/medio livello ...","","","","V ADPQ "],["783","Nuovo Osp.","783"," ","Dip Medicina","USSD Pronto Soccorso","","Elettrobisturi","ELB","1","10.000","0","per sala piccoli interventi","","","","Senza Fin. "],["815","Nuovo Osp.","815"," ","Dip Materno-Infantile e Pediatrico","USC Chirurgia Pediatrica","","Elettrobisturi","ELB","1","6.000","0","per ambulatorio piccoli interventi","","","","Senza Fin. "],["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 "],["1227","Nuovo Osp.","1227","27/05/2009","Dip Cardiovascolare","USC Chirurgia Vascolare","","Elettrobisturi","ELB","1","10.000","","per Ambulatorio
Manca visto ...","","","","Senza Fin. "],["1725","Nuovo Osp.","1725"," ","Dip Cardiovascolare","USC Cardiologia II - Diagnostica Int ...","","elettrobisturi","ELB","1","6.000","","richiesta 28/1/2010","","","","Senza Fin. "]] }[/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]
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
[code]var aData = oTable.fnGetData( this );[/code]
When the table is empty... this line make something "bad"
Michele.
Allan