1
0
mirror of https://github.com/DataTables/DataTables.git synced 2025-01-30 23:52:11 +01:00

Fix: When a column of only TH elements is used in the table it would cause indexing problems for the width calculation due to a getElementsByTagName('td'). Now use the _fnGetTdNodes (slightly modified) to do this.

This commit is contained in:
Allan Jardine 2011-05-07 10:37:22 +01:00
parent e4390f8b00
commit 96d0b163ce

View File

@ -5542,7 +5542,7 @@
iCorrector++; iCorrector++;
} }
} }
/* Find the biggest td for each column and put it into the table */ /* Find the biggest td for each column and put it into the table */
for ( i=0 ; i<iColums ; i++ ) for ( i=0 ; i<iColums ; i++ )
{ {
@ -5663,7 +5663,7 @@
); );
return n; return n;
} }
return oSettings.aoData[iMaxIndex].nTr.getElementsByTagName('td')[iVis]; return _fnGetTdNodes(oSettings, iMaxIndex)[iVis];
} }
/* /*
@ -5830,19 +5830,33 @@
/* /*
* Function: _fnGetTdNodes * Function: _fnGetTdNodes
* Purpose: Return an flat array with all TD nodes for the table * Purpose: Return an flat array with all TD nodes for the table, or row
* Returns: array: - TD array * Returns: array: - TD array
* Inputs: object:oSettings - dataTables settings object * Inputs: object:oSettings - dataTables settings object
* int:iIndividualRow - aoData index to get the nodes for - optional if not
* given then the return array will contain all nodes for the table
*/ */
function _fnGetTdNodes ( oSettings ) function _fnGetTdNodes ( oSettings, iIndividualRow )
{ {
var anReturn = []; var anReturn = [];
var iCorrector; var iCorrector;
var anTds; var anTds;
var iRow, iRows=oSettings.aoData.length, var iRow, iRows=oSettings.aoData.length,
iColumn, iColumns, oData, sNodeName; iColumn, iColumns, oData, sNodeName;
/* Allow the collection to be limited to just one row */
if ( typeof iRow == 'undefined' )
{
iStart = iIndividualRow;
iEnd = iIndividualRow+1;
}
else
{
iStart = 0;
iEnd = iRows;
}
for ( iRow=0 ; iRow<iRows ; iRow++ ) for ( iRow=iStart ; iRow<iEnd ; iRow++ )
{ {
oData = oSettings.aoData[iRow]; oData = oSettings.aoData[iRow];
if ( oData.nTr !== null ) if ( oData.nTr !== null )