Show/hide details and fnDraw()
Show/hide details and fnDraw()
Hi
I have a small problem. I use the processing on the server side and using fnDraw() for updates the table every 30 seconds. But it is closing all the open rows.
How to make sure that they were not closed during the upgrade?
My code:
[code]
var oTable;
/* Formating function for row details */
function fnFormatDetails ( nTr )
{
var aData = oTable.fnGetData( nTr );
var sOut = '';
sOut += '"'+aData[0]+'\"/>';
sOut += '';
return sOut;
}
/* -------------------------------------------- */
$(document).ready(function() {
oTable = $('#example').dataTable( {
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"bProcessing": false,
"bServerSide": true,
"sAjaxSource": "lobby/free_th_nl.php",
"aoColumns": [
{ "sClass": "center" },
{ "sClass": "left" },
{ "sClass": "center", "bSortable": false}
],
"aaSorting": [[0, 'asc']],
"fnDrawCallback": function() {
$("#example tbody tr").click(function () {var nTr = this;
if ( $(this).hasClass('row_selected') ) {$(this).removeClass('row_selected');oTable.fnClose(nTr);}else{
$(this).addClass('row_selected');oTable.fnOpen( nTr, fnFormatDetails(nTr), 'details' );}
});
},
"bStateSave": true,
"iDisplayLength": "25"
} );
setInterval('oTable.fnDraw()', 30000);
} );
[/code]
I have a small problem. I use the processing on the server side and using fnDraw() for updates the table every 30 seconds. But it is closing all the open rows.
How to make sure that they were not closed during the upgrade?
My code:
[code]
var oTable;
/* Formating function for row details */
function fnFormatDetails ( nTr )
{
var aData = oTable.fnGetData( nTr );
var sOut = '';
sOut += '"'+aData[0]+'\"/>';
sOut += '';
return sOut;
}
/* -------------------------------------------- */
$(document).ready(function() {
oTable = $('#example').dataTable( {
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"bProcessing": false,
"bServerSide": true,
"sAjaxSource": "lobby/free_th_nl.php",
"aoColumns": [
{ "sClass": "center" },
{ "sClass": "left" },
{ "sClass": "center", "bSortable": false}
],
"aaSorting": [[0, 'asc']],
"fnDrawCallback": function() {
$("#example tbody tr").click(function () {var nTr = this;
if ( $(this).hasClass('row_selected') ) {$(this).removeClass('row_selected');oTable.fnClose(nTr);}else{
$(this).addClass('row_selected');oTable.fnOpen( nTr, fnFormatDetails(nTr), 'details' );}
});
},
"bStateSave": true,
"iDisplayLength": "25"
} );
setInterval('oTable.fnDraw()', 30000);
} );
[/code]
This discussion has been closed.
Replies
What needs to be done is to keep track of which rows are open (see this blog post: http://datatables.net/blog/Drill-down_rows ) and then re-open them with fnDrawCallback.
Allan