Skip to content

Commit

Permalink
Fix: With scrolling enabled, adding the scrollbar width to the header…
Browse files Browse the repository at this point in the history
… / 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.
  • Loading branch information
Allan Jardine committed Jan 30, 2012
1 parent 019b235 commit 876a75f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
9 changes: 4 additions & 5 deletions media/js/jquery.dataTables.js
Expand Up @@ -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 );
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 );
}

Expand Down
9 changes: 4 additions & 5 deletions media/src/core/core.scrolling.js
Expand Up @@ -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 );
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 );
}

Expand Down

0 comments on commit 876a75f

Please sign in to comment.