mirror of
https://github.com/DataTables/DataTables.git
synced 2025-01-19 12:52:11 +01:00
Merge pull request #87 from timtucker/patch-4
Allow adding / removing an arbitrary number of stripes
This commit is contained in:
commit
1fdfb65457
@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform a jQuery selector action on the table's TR elements (from the tbody) and
|
* Perform a jQuery selector action on the table's TR elements (from the tbody) and
|
||||||
* return the resulting jQuery object.
|
* return the resulting jQuery object.
|
||||||
@ -566,12 +564,19 @@ this.fnDestroy = function ( bRemove )
|
|||||||
oSettings.nTable.style.width = _fnStringToCss(oSettings.sDestroyWidth);
|
oSettings.nTable.style.width = _fnStringToCss(oSettings.sDestroyWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the were originally odd/even type classes - then we add them back here. Note
|
/* If the were originally stripe classes - then we add them back here. Note
|
||||||
* this is not fool proof (for example if not all rows as odd/even classes - but
|
* this is not fool proof (for example if not all rows had stripe classes - but
|
||||||
* it's a good effort without getting carried away
|
* it's a good effort without getting carried away
|
||||||
*/
|
*/
|
||||||
$(nBody).children('tr:even').addClass( oSettings.asDestroyStripes[0] );
|
iLen = oSettings.asDestroyStripes.length;
|
||||||
$(nBody).children('tr:odd').addClass( oSettings.asDestroyStripes[1] );
|
if (iLen)
|
||||||
|
{
|
||||||
|
var anRows = $(nBody).children('tr');
|
||||||
|
for ( i=0 ; i<iLen ; i++ )
|
||||||
|
{
|
||||||
|
anRows.filter(':nth-child(' + iLen + 'n + ' + i + ')').addClass( oSettings.asDestroyStripes[i] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Remove the settings object from the settings array */
|
/* Remove the settings object from the settings array */
|
||||||
for ( i=0, iLen=DataTable.settings.length ; i<iLen ; i++ )
|
for ( i=0, iLen=DataTable.settings.length ; i<iLen ; i++ )
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
var i=0, iLen, j, jLen, k, kLen;
|
var i=0, iLen, j, jLen, k, kLen;
|
||||||
var sId = this.getAttribute( 'id' );
|
var sId = this.getAttribute( 'id' );
|
||||||
var bInitHandedOff = false;
|
var bInitHandedOff = false;
|
||||||
@ -240,41 +239,28 @@ if ( oInit.asStripeClasses === null )
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Remove row stripe classes if they are already on the table row */
|
/* Remove row stripe classes if they are already on the table row */
|
||||||
var bStripeRemove = false;
|
iLen=oSettings.asStripeClasses.length;
|
||||||
var anRows = $(this).children('tbody').children('tr');
|
oSettings.asDestroyStripes = [];
|
||||||
for ( i=0, iLen=oSettings.asStripeClasses.length ; i<iLen ; i++ )
|
if (iLen)
|
||||||
{
|
{
|
||||||
if ( anRows.filter(":lt(2)").hasClass( oSettings.asStripeClasses[i]) )
|
var bStripeRemove = false;
|
||||||
|
var anRows = $(this).children('tbody').children('tr:lt(' + iLen + ')');
|
||||||
|
for ( i=0 ; i<iLen ; i++ )
|
||||||
|
{
|
||||||
|
if ( anRows.hasClass( oSettings.asStripeClasses[i] ) )
|
||||||
{
|
{
|
||||||
bStripeRemove = true;
|
bStripeRemove = true;
|
||||||
break;
|
|
||||||
|
/* Store the classes which we are about to remove so they can be re-added on destroy */
|
||||||
|
oSettings.asDestroyStripes.push( oSettings.asStripeClasses[i] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( bStripeRemove )
|
if ( bStripeRemove )
|
||||||
{
|
{
|
||||||
/* Store the classes which we are about to remove so they can be re-added on destroy */
|
|
||||||
oSettings.asDestroyStripes = [ '', '' ];
|
|
||||||
if ( $(anRows[0]).hasClass(oSettings.oClasses.sStripeOdd) )
|
|
||||||
{
|
|
||||||
oSettings.asDestroyStripes[0] += oSettings.oClasses.sStripeOdd+" ";
|
|
||||||
}
|
|
||||||
if ( $(anRows[0]).hasClass(oSettings.oClasses.sStripeEven) )
|
|
||||||
{
|
|
||||||
oSettings.asDestroyStripes[0] += oSettings.oClasses.sStripeEven;
|
|
||||||
}
|
|
||||||
if ( $(anRows[1]).hasClass(oSettings.oClasses.sStripeOdd) )
|
|
||||||
{
|
|
||||||
oSettings.asDestroyStripes[1] += oSettings.oClasses.sStripeOdd+" ";
|
|
||||||
}
|
|
||||||
if ( $(anRows[1]).hasClass(oSettings.oClasses.sStripeEven) )
|
|
||||||
{
|
|
||||||
oSettings.asDestroyStripes[1] += oSettings.oClasses.sStripeEven;
|
|
||||||
}
|
|
||||||
|
|
||||||
anRows.removeClass( oSettings.asStripeClasses.join(' ') );
|
anRows.removeClass( oSettings.asStripeClasses.join(' ') );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Columns
|
* Columns
|
||||||
|
Loading…
x
Reference in New Issue
Block a user