From 332d511649ac0651dcd930d44071080d99720d86 Mon Sep 17 00:00:00 2001 From: Allan Jardine Date: Wed, 8 Sep 2010 20:40:18 +0100 Subject: [PATCH] Fixed: Destroying a scrolling table was not correctly reassembling the table from it's component parts which are split up for scrolling. --- media/js/jquery.dataTables.js | 57 +++++++++---------- media/unit_testing/tests_onhold/1_dom/2569.js | 16 ++++++ .../tests_onhold/4_server-side/2569.js | 47 +++++++++++++++ 3 files changed, 89 insertions(+), 31 deletions(-) create mode 100755 media/unit_testing/tests_onhold/4_server-side/2569.js diff --git a/media/js/jquery.dataTables.js b/media/js/jquery.dataTables.js index 78cdbdd4..5eb0fd96 100644 --- a/media/js/jquery.dataTables.js +++ b/media/js/jquery.dataTables.js @@ -2060,6 +2060,19 @@ } } + /* When scrolling we had to break the table up - restore it */ + if ( oSettings.nTable != oSettings.nTHead.parentNode ) + { + $('>thead', oSettings.nTable).remove(); + oSettings.nTable.appendChild( oSettings.nTHead ); + } + + if ( oSettings.nTFoot && oSettings.nTable != oSettings.nTFoot.parentNode ) + { + $('>tfoot', oSettings.nTable).remove(); + oSettings.nTable.appendChild( oSettings.nTFoot ); + } + /* Remove the DataTables generated nodes, events and classes */ oSettings.nTable.parentNode.removeChild( oSettings.nTable ); $(oSettings.nTableWrapper).remove(); @@ -2204,7 +2217,7 @@ /* Draw the headers for the table */ _fnDrawHead( oSettings ); - /* Calculate sizes for columns xxx */ + /* Calculate sizes for columns */ if ( oSettings.oFeatures.bAutoWidth ) { _fnCalculateColumnWidths( oSettings ); @@ -3020,36 +3033,6 @@ } } - /* Perform certain DOM operations after the table has been drawn for the first time */ - if ( typeof oSettings._bInitComplete == "undefined" ) - { - oSettings._bInitComplete = true; - - /* It is possible that some of the DOM created (particularly if custom) has padding etc - * on it which means that the table size is more constrained that when we originally - * measured it. As such we check here if this is the case, and correct if needed - */ - if ( oSettings.nTableWrapper != oSettings.nTable.parentNode && - $(oSettings.nTableWrapper).width() > $(oSettings.nTable.parentNode).width() ) - { - _fnAjustColumnSizing( oSettings ); - } - - if ( typeof oSettings.fnInitComplete == 'function' && - (oSettings.oFeatures.bServerSide || oSettings.sAjaxSource === null) ) - { - oSettings.fnInitComplete.call( oSettings.oInstance, oSettings ); - } - - /* Set an absolute width for the table such that pagination doesn't - * cause the table to resize - disabled for now. - */ - //if ( oSettings.oFeatures.bAutoWidth && oSettings.nTable.offsetWidth !== 0 ) - //{ - // //oSettings.nTable.style.width = oSettings.nTable.offsetWidth+"px"; - //} - } - /* Call all required callback functions for the end of a draw */ for ( i=0, iLen=oSettings.aoDrawCallback.length ; i