ydn-js origin
YUI version 2.5.2
Conditional row coloring
Challenge
Highlight any number of rows based on the value in a column. Preserve coloring across sorting.
Considerations
- Currently the row element is not provided to the cell formatter, and is not easily available until after the table is fully rendered.
- Due to CSS restrictions in IE, cross browser row striping is not possible for consecutive colored rows (e.g. using a slightly darker shade of the color for the odd rows).
- DataTable reuses existing
tr
elements when sorting, so the coloring class needs to be removed from the rows before and reapplied after sorting.
Solution
Use a custom formatter to cache the records that will need to have their corresponding rows colored, then apply the row coloring in a renderEvent handler.