[RESOLVED] fndraw() help
[RESOLVED] fndraw() help
organicspider
Posts: 12Questions: 0Answers: 0
I am trying to refresh my table every 10 seconds using the following code[code]
$(document).ready(function() {
var oTable;
oTable = $('#asterisk-cdr').dataTable( {
"bProcessing": true,
"bServerSide": true,
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"aoColumnDefs": [ { "sClass": "center", "aTargets": [ 0, 1, 2, 3, 4, 5, 6, 7] } ],
"aoColumns": [ null, { "bSearchable": false }, null , { "bVisible": false, "bSearchable": false } , { "bVisible": false, "bSearchable": false } , null, null, null ],
"sAjaxSource": "/media/php/cdr.php",
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
var sDirectionClass; var sSrc = aData[3]; var sDst = aData[4];
if ( aData[1] == "0" ) {
sDirectionClass = "inbound"; $('td:eq(2)', nRow).html( sSrc );
$('td:eq(1)', nRow).html( '' );
} else {
sDirectionClass = "outbound"; $('td:eq(2)', nRow).html( sDst );
$('td:eq(1)', nRow).html( '' );
}
$(nRow).addClass( sDirectionClass );
return nRow;
}
} );
setInterval(function() { oTable.fnDraw; }, 10000);
} );
[/code]but it is never being re-drawn :( if I add an alert before the fndraw that pops up fine every 10 seconds. Am I setting oTable in the wrong place ?
$(document).ready(function() {
var oTable;
oTable = $('#asterisk-cdr').dataTable( {
"bProcessing": true,
"bServerSide": true,
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"aoColumnDefs": [ { "sClass": "center", "aTargets": [ 0, 1, 2, 3, 4, 5, 6, 7] } ],
"aoColumns": [ null, { "bSearchable": false }, null , { "bVisible": false, "bSearchable": false } , { "bVisible": false, "bSearchable": false } , null, null, null ],
"sAjaxSource": "/media/php/cdr.php",
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
var sDirectionClass; var sSrc = aData[3]; var sDst = aData[4];
if ( aData[1] == "0" ) {
sDirectionClass = "inbound"; $('td:eq(2)', nRow).html( sSrc );
$('td:eq(1)', nRow).html( '' );
} else {
sDirectionClass = "outbound"; $('td:eq(2)', nRow).html( sDst );
$('td:eq(1)', nRow).html( '' );
}
$(nRow).addClass( sDirectionClass );
return nRow;
}
} );
setInterval(function() { oTable.fnDraw; }, 10000);
} );
[/code]but it is never being re-drawn :( if I add an alert before the fndraw that pops up fine every 10 seconds. Am I setting oTable in the wrong place ?
This discussion has been closed.
Replies