sorttable bug: striped-tables

When analysing the table on startup, try and DWIM whether
it’s using CSS to provide striping. If it is, reapply the
striping afterwards so that sorting doesn’t screw up the
look of the table.

Dwimming this might be hard. We need to check for:
# every odd row having one class, every even row having a different class
# if not, then check for some style that’s on all odd rows and some different style on all even rows
# failing that, check for some style that’s on all odd rows, with no corresponding style on even rows, and vice versa

Note that checking for “some style” is potentially very hard.
We can probably assume that striping is done with background colour,
so check the background colour for the first td in each row.
If they alternate, then the table’s striped: go into DWIM mode to
work out how the striping is applied.

The background colour has to be checked in the computed style
(runtimeStyle in IE), not as td.style.backgroundColor, because it
might be applied to the parent tr.

Note that the striping might be applied in any of the following ways:

  1. tr class=“even” ... tr class=“odd”
  2. tr td class=“even” td class=“even” ... tr td class=“odd” td class=“odd”
  3. tr class=“stripe” ... tr
  4. tr style=“background-color: red” ... tr (will this work?)
  5. tr style=“background-color: red” ... tr style=“background-color: yellow” (will this work?)
  6. tr td style=“background-color: red” ... tr
  7. tr td style=“background-color: red” ... tr td style=“background-color: yellow”

Back to the sorttable bug list

Email me when this bug gets updated: · privacy · powered by ChangeDetection