1
0
mirror of https://github.com/DataTables/DataTables.git synced 2024-12-01 13:24:10 +01:00

Fix: When filtering is applied to a table which has y-scrolling, and the filter was sufficient to make the scrolling disappear, the table width would increase by the scrollbar width. This was of course incorrect and the result of a change for 1.8.1 - we need to test is the scrollbar is present or not for the fix to be correct, which it now does. Unit test added.

Fix: As with the fix in 1.8.1 for the x-scrolling appearing when disabled the footer needs the same consideration as the header, otherwise it can be cut off visually.
This commit is contained in:
Allan Jardine 2011-06-29 18:08:14 +01:00
parent 38cf5b6928
commit 2c9ce2aa59
2 changed files with 36 additions and 8 deletions

View File

@ -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 );
}

View File

@ -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();
} );