mirror of
https://github.com/DataTables/DataTables.git
synced 2025-03-01 02:54:15 +01:00
Fix: New algorithim for calculating the column widths for a table when x-scrolling is enabled. Basically browsers need a bit of a hand when a width is assigned to any columns when x-scrolling as they tend to collapse the table to the min-width, even if we sent the column widths. So we need to keep track of what the table width should be by summing the user given values, and the automatic values
This commit is contained in:
parent
84a1940cad
commit
99b674def8
30
media/js/jquery.dataTables.js
vendored
30
media/js/jquery.dataTables.js
vendored
@ -5610,6 +5610,36 @@
|
|||||||
oNodes = _fnGetUniqueThs( oSettings, $('thead', nCalcTmp)[0] );
|
oNodes = _fnGetUniqueThs( oSettings, $('thead', nCalcTmp)[0] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Browsers need a bit of a hand when a width is assigned to any columns when
|
||||||
|
* x-scrolling as they tend to collapse the table to the min-width, even if
|
||||||
|
* we sent the column widths. So we need to keep track of what the table width
|
||||||
|
* should be by summing the user given values, and the automatic values
|
||||||
|
*/
|
||||||
|
if ( oSettings.oScroll.sX !== "" )
|
||||||
|
{
|
||||||
|
var iTotal = 0;
|
||||||
|
iCorrector = 0;
|
||||||
|
for ( i=0 ; i<oSettings.aoColumns.length ; i++ )
|
||||||
|
{
|
||||||
|
if ( oSettings.aoColumns[i].bVisible )
|
||||||
|
{
|
||||||
|
if ( oSettings.aoColumns[i].sWidthOrig === null )
|
||||||
|
{
|
||||||
|
iTotal += $(oNodes[iCorrector]).outerWidth();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
iTotal += parseInt(oSettings.aoColumns[i].sWidth.replace('px','')) +
|
||||||
|
($(oNodes[iCorrector]).outerWidth() - $(oNodes[iCorrector]).width());
|
||||||
|
}
|
||||||
|
iCorrector++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nCalcTmp.style.width = _fnStringToCss( iTotal );
|
||||||
|
oSettings.nTable.style.width = _fnStringToCss( iTotal );
|
||||||
|
}
|
||||||
|
|
||||||
iCorrector = 0;
|
iCorrector = 0;
|
||||||
for ( i=0 ; i<oSettings.aoColumns.length ; i++ )
|
for ( i=0 ; i<oSettings.aoColumns.length ; i++ )
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user