From aca54b93848757aca6a9ad37d58da625730a14a8 Mon Sep 17 00:00:00 2001 From: Allan Jardine Date: Tue, 2 Feb 2016 16:28:54 +0000 Subject: [PATCH] Fix: Improved DOM ordering for scrolling tables - colgroup, thead, tfoot - Fixes DataTables/FixedColumns #8 --- js/core/core.scrolling.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/js/core/core.scrolling.js b/js/core/core.scrolling.js index 868e4d34f..5c13cf90c 100644 --- a/js/core/core.scrolling.js +++ b/js/core/core.scrolling.js @@ -227,18 +227,18 @@ function _fnScrollDraw ( settings ) // Remove the old minimised thead and tfoot elements in the inner table table.children('thead, tfoot').remove(); - // Clone the current header and footer elements and then place it into the inner table - headerCopy = header.clone().prependTo( table ); - headerTrgEls = header.find('tr'); // original header is in its own table - headerSrcEls = headerCopy.find('tr'); - headerCopy.find('th, td').removeAttr('tabindex'); - if ( footer ) { footerCopy = footer.clone().prependTo( table ); footerTrgEls = footer.find('tr'); // the original tfoot is in its own table and must be sized footerSrcEls = footerCopy.find('tr'); } + // Clone the current header and footer elements and then place it into the inner table + headerCopy = header.clone().prependTo( table ); + headerTrgEls = header.find('tr'); // original header is in its own table + headerSrcEls = headerCopy.find('tr'); + headerCopy.find('th, td').removeAttr('tabindex'); + /* * 2. Take live measurements from the DOM - do not alter the DOM itself! @@ -418,6 +418,9 @@ function _fnScrollDraw ( settings ) divFooterInner[0].style[padding] = bScrolling ? barWidth+"px" : "0px"; } + // Correct DOM ordering for colgroup - comes before the thead + table.children('colgroup').insertBefore( table.children('thead') ); + /* Adjust the position of the header in case we loose the y-scrollbar */ divBody.scroll();