diff --git a/media/js/jquery.dataTables.js b/media/js/jquery.dataTables.js index 0ebadbdd..d78dfea1 100644 --- a/media/js/jquery.dataTables.js +++ b/media/js/jquery.dataTables.js @@ -1,4 +1,4 @@ -/* +/* * File: jquery.dataTables.js * Version: 1.8.2.dev * Description: Paginate, search and sort HTML tables @@ -3938,7 +3938,9 @@ nScrollHeadTable = nScrollHeadInner.getElementsByTagName('table')[0], nScrollBody = o.nTable.parentNode, i, iLen, j, jLen, anHeadToSize, anHeadSizers, anFootSizers, anFootToSize, oStyle, iVis, - iWidth, aApplied=[], iSanityWidth; + iWidth, aApplied=[], iSanityWidth, + nScrollFootInner = (o.nTFoot !== null) ? o.nScrollFoot.getElementsByTagName('div')[0] : null, + nScrollFootTable = (o.nTFoot !== null) ? nScrollFootInner.getElementsByTagName('table')[0] : null; /* * 1. Re-create the table inside the scrolling div @@ -4048,8 +4050,15 @@ /* If x-scrolling is disabled, then the viewport cannot be less than the sanity width */ if ( o.oScroll.sX === "" ) { - nScrollBody.style.width = _fnStringToCss( iSanityWidth+o.oScroll.iBarWidth ); - nScrollHeadInner.parentNode.style.width = _fnStringToCss( iSanityWidth+o.oScroll.iBarWidth ); + var iCorrection = (nScrollBody.scrollHeight > nScrollBody.offsetHeight) ? + iSanityWidth+o.oScroll.iBarWidth : iSanityWidth; + nScrollBody.style.width = _fnStringToCss( iCorrection ); + nScrollHeadInner.parentNode.style.width = _fnStringToCss( iCorrection ); + + if ( o.nTFoot !== null ) + { + nScrollFootInner.parentNode.style.width = _fnStringToCss( iCorrection ); + } } /* We want the hidden header to have zero height, so remove padding and borders. Then @@ -4169,10 +4178,6 @@ if ( o.nTFoot !== null ) { - var - nScrollFootInner = o.nScrollFoot.getElementsByTagName('div')[0], - nScrollFootTable = nScrollFootInner.getElementsByTagName('table')[0]; - nScrollFootInner.style.width = _fnStringToCss( o.nTable.offsetWidth+o.oScroll.iBarWidth ); nScrollFootTable.style.width = _fnStringToCss( o.nTable.offsetWidth ); } diff --git a/media/unit_testing/tests_onhold/1_dom/5508-xscroll-zero-content.js b/media/unit_testing/tests_onhold/1_dom/5508-xscroll-zero-content.js new file mode 100755 index 00000000..f71ae8f4 --- /dev/null +++ b/media/unit_testing/tests_onhold/1_dom/5508-xscroll-zero-content.js @@ -0,0 +1,23 @@ +// DATA_TEMPLATE: dom_data +oTest.fnStart( "5508 - Table container width doesn't change when filtering applied to scrolling table" ); + +$(document).ready( function () { + $('#example').dataTable( { + "sScrollY": "300px", + "bPaginate": false + } ); + + oTest.fnTest( + "Width of container 800px on init with scroll", + null, + function () { return $('div.dataTables_scrollBody').width() == 800; } + ); + + oTest.fnTest( + "Unaltered when filter applied", + function () { $('#example').dataTable().fnFilter('123'); }, + function () { return $('div.dataTables_scrollBody').width() == 800; } + ); + + oTest.fnComplete(); +} ); \ No newline at end of file