Show/hide details and fnDraw()

Show/hide details and fnDraw()

seocustomseocustom Posts: 1Questions: 0Answers: 0
edited April 2011 in General
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]

Replies

  • darlenedarlene Posts: 3Questions: 0Answers: 0
    Did you find a solution to this? I have a similar issue -- events that trigger a table redraw, but the update closes all the open row details.
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    You can see this in the demos actually: http://datatables.net/release-datatables/examples/server_side/row_details.html . What is happening is that the DOM is being created on-the-fly with server-side processing, thus DataTables don't know that the rows you are now displaying are the same as before - and can't attach the elements again.

    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
This discussion has been closed.