Striping Issue

Striping Issue

bebrooks1bebrooks1 Posts: 1Questions: 0Answers: 0
edited March 2013 in General
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.

Replies

  • SorensenSorensen Posts: 3Questions: 0Answers: 0
    Hello! I just found the same thing today as I was testing the upgrade from 1.9.2 to 1.9.4.

    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
  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    This has actually already been fixed in git: https://github.com/DataTables/DataTables/commit/cab0c53 . Its not yet made it into a release though I'm afraid - it will be in 1.10 when that is available though.

    Regards,
    Allan
  • SorensenSorensen Posts: 3Questions: 0Answers: 0
    Even better! Thanks!
This discussion has been closed.