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

Dev: Tidy up _fnColumnIndexToVisible and _fnVisibleToColumnIndex to use the new _fnGetColumns method.

This commit is contained in:
Allan Jardine 2012-07-31 09:39:51 +01:00
parent d034d187bd
commit 5311067cd2
2 changed files with 18 additions and 62 deletions

View File

@ -229,22 +229,11 @@
*/
function _fnVisibleToColumnIndex( oSettings, iMatch )
{
var iColumn = -1;
for ( var i=0 ; i<oSettings.aoColumns.length ; i++ )
{
if ( oSettings.aoColumns[i].bVisible === true )
{
iColumn++;
}
if ( iColumn == iMatch )
{
return i;
}
}
return null;
var aiVis = _fnGetColumns( oSettings, 'bVisible' );
return typeof aiVis[iMatch] === 'number' ?
aiVis[iMatch] :
null;
}
@ -258,21 +247,10 @@
*/
function _fnColumnIndexToVisible( oSettings, iMatch )
{
var iVisible = -1;
for ( var i=0 ; i<oSettings.aoColumns.length ; i++ )
{
if ( oSettings.aoColumns[i].bVisible === true )
{
iVisible++;
}
if ( i == iMatch )
{
return oSettings.aoColumns[i].bVisible === true ? iVisible : null;
}
}
return null;
var aiVis = _fnGetColumns( oSettings, 'bVisible' );
var iPos = $.inArray( iMatch, aiVis );
return iPos !== -1 ? iPos : null;
}

View File

@ -169,22 +169,11 @@ function _fnAdjustColumnSizing ( oSettings )
*/
function _fnVisibleToColumnIndex( oSettings, iMatch )
{
var iColumn = -1;
for ( var i=0 ; i<oSettings.aoColumns.length ; i++ )
{
if ( oSettings.aoColumns[i].bVisible === true )
{
iColumn++;
}
if ( iColumn == iMatch )
{
return i;
}
}
return null;
var aiVis = _fnGetColumns( oSettings, 'bVisible' );
return typeof aiVis[iMatch] === 'number' ?
aiVis[iMatch] :
null;
}
@ -198,21 +187,10 @@ function _fnVisibleToColumnIndex( oSettings, iMatch )
*/
function _fnColumnIndexToVisible( oSettings, iMatch )
{
var iVisible = -1;
for ( var i=0 ; i<oSettings.aoColumns.length ; i++ )
{
if ( oSettings.aoColumns[i].bVisible === true )
{
iVisible++;
}
if ( i == iMatch )
{
return oSettings.aoColumns[i].bVisible === true ? iVisible : null;
}
}
return null;
var aiVis = _fnGetColumns( oSettings, 'bVisible' );
var iPos = $.inArray( iMatch, aiVis );
return iPos !== -1 ? iPos : null;
}