Striping Issue
Striping Issue
I'm currently having an issue where the striping on the table gets messed up. The stripes don't alternate. If you look at the html on the table, it ends up looking like this:
....etc
This continues on without any real pattern however it looks like the last class listed is always the correct class. I'm currently using datatables 1.9.4. Has anyone experienced this before? I searched through the forum and only found one incidence of this however there didn't seem to be a solution.
....etc
This continues on without any real pattern however it looks like the last class listed is always the correct class. I'm currently using datatables 1.9.4. Has anyone experienced this before? I searched through the forum and only found one incidence of this however there didn't seem to be a solution.
This discussion has been closed.
Replies
In my case, I have a DOM table pre-striped with "odd" and "even" class names for alternating rows. This then gets enhanced by DataTables, and the classes get confused. If your situation is similar, I know just the thing!
In DataTables, the pre-striped class names get removed (if they are equal to the names of the classes specified by asStripeClasses). This can be seen the code starting around line 6431 in version 1.9.2. However, I believe there is a regression in version 1.9.4 that does not remove the classes properly. In this version, the pre-stripe removal starts at line 6607.
Specifically, relevant line is as follows: [code]anRows.removeClass( oSettings.asStripeClasses.join(' ') );[/code]
In version 1.9.2, this is at 6464; in 1.9.4, this is 6627. The problem is that anRows has changed. In 1.9.2, anRows is all s in the . Later, this gets sub-filtered to just the first N rows, where N is the number of stripes, in order to do some fnDestroy bookkeeping. However, in 1.9.4, anRows is already filtered to just the N rows, so only the top N rows get their pre-striped classes removed.
The fix is pretty straightforward. Starting at line 6611:
[code]
{
var bStripeRemove = false;
var anRows = $(this).children('tbody').children('tr');
var anRowsTop = anRows.filter(':lt(' + iLen + ')');
for ( i=0 ; i
Regards,
Allan