From 876a75f6ad046ffe699e8c0e4702fc132b61dda3 Mon Sep 17 00:00:00 2001 From: Allan Jardine Date: Mon, 30 Jan 2012 09:52:35 +0000 Subject: [PATCH] Fix: With scrolling enabled, adding the scrollbar width to the header / footer inner container elements could cause the table to resize incorrectly on the following draw (and this error was cumulative). Fix is not to adjust the inner element for the scrollbar width - makes no difference to the table draw. It is possible that if you've styled this element you might need to take this change into account, but by default DataTables will style the parent (scrollHead) so no change is required (regardless of jQuery UI theming enablement) - 6776. Fix: The calculation to detect if the scroll bar would be shown in IE6/7 was incorrect - it was calculating the height of the entire table, rather than just the body of the table (i.e. body + header + footer) which caused the "correct" for the scrollbar to be incorrectly applied to small tables. --- media/js/jquery.dataTables.js | 9 ++++----- media/src/core/core.scrolling.js | 9 ++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/media/js/jquery.dataTables.js b/media/js/jquery.dataTables.js index 3376d16e..88c09259 100644 --- a/media/js/jquery.dataTables.js +++ b/media/js/jquery.dataTables.js @@ -3127,8 +3127,8 @@ * the scrollbar - which is shouldn't. When there is a scrollbar we need to take this * into account. */ - if ( ie67 && (nScrollBody.scrollHeight > - nScrollBody.offsetHeight || $(nScrollBody).css('overflow-y') == "scroll") ) + if ( ie67 && ($('tbody', nScrollBody).height() > nScrollBody.offsetHeight || + $(nScrollBody).css('overflow-y') == "scroll") ) { o.nTable.style.width = _fnStringToCss( $(o.nTable).outerWidth()-o.oScroll.iBarWidth ); } @@ -3279,7 +3279,6 @@ /* * 4. Clean up */ - if ( o.oScroll.sY === "" ) { /* IE7< puts a vertical scrollbar in place (when it shouldn't be) due to subtracting @@ -3307,11 +3306,11 @@ /* Finally set the width's of the header and footer tables */ var iOuterWidth = $(o.nTable).outerWidth(); nScrollHeadTable.style.width = _fnStringToCss( iOuterWidth ); - nScrollHeadInner.style.width = _fnStringToCss( iOuterWidth+o.oScroll.iBarWidth ); + nScrollHeadInner.style.width = _fnStringToCss( iOuterWidth ); if ( o.nTFoot !== null ) { - nScrollFootInner.style.width = _fnStringToCss( o.nTable.offsetWidth+o.oScroll.iBarWidth ); + nScrollFootInner.style.width = _fnStringToCss( o.nTable.offsetWidth ); nScrollFootTable.style.width = _fnStringToCss( o.nTable.offsetWidth ); } diff --git a/media/src/core/core.scrolling.js b/media/src/core/core.scrolling.js index 46c51866..4b13bfde 100644 --- a/media/src/core/core.scrolling.js +++ b/media/src/core/core.scrolling.js @@ -256,8 +256,8 @@ function _fnScrollDraw ( o ) * the scrollbar - which is shouldn't. When there is a scrollbar we need to take this * into account. */ - if ( ie67 && (nScrollBody.scrollHeight > - nScrollBody.offsetHeight || $(nScrollBody).css('overflow-y') == "scroll") ) + if ( ie67 && ($('tbody', nScrollBody).height() > nScrollBody.offsetHeight || + $(nScrollBody).css('overflow-y') == "scroll") ) { o.nTable.style.width = _fnStringToCss( $(o.nTable).outerWidth()-o.oScroll.iBarWidth ); } @@ -408,7 +408,6 @@ function _fnScrollDraw ( o ) /* * 4. Clean up */ - if ( o.oScroll.sY === "" ) { /* IE7< puts a vertical scrollbar in place (when it shouldn't be) due to subtracting @@ -436,11 +435,11 @@ function _fnScrollDraw ( o ) /* Finally set the width's of the header and footer tables */ var iOuterWidth = $(o.nTable).outerWidth(); nScrollHeadTable.style.width = _fnStringToCss( iOuterWidth ); - nScrollHeadInner.style.width = _fnStringToCss( iOuterWidth+o.oScroll.iBarWidth ); + nScrollHeadInner.style.width = _fnStringToCss( iOuterWidth ); if ( o.nTFoot !== null ) { - nScrollFootInner.style.width = _fnStringToCss( o.nTable.offsetWidth+o.oScroll.iBarWidth ); + nScrollFootInner.style.width = _fnStringToCss( o.nTable.offsetWidth ); nScrollFootTable.style.width = _fnStringToCss( o.nTable.offsetWidth ); }