Yahoo! Developer Network Home - Help

YUI Library Examples: DataTable Control (beta): Conditional row coloring

DataTable Control (beta): Conditional row coloring

This example demonstrates how to color DataTable rows based on data in a cell. In this case, rows with Quantity less than 40 are highlighted.

CSS

We nullify the default coloring for a simpler looking table with the marked rows really standing out.

Markup:

JavaScript:

Using a custom formatter, records that need to have their corresponding rows colored are stored in a collection outside the DataTable. Then the DataTable's renderEvent is subscribed to with a function to apply the mark class to the appropriate rows.

Copyright © 2008 Yahoo! Inc. All rights reserved.

Privacy Policy - Terms of Service - Copyright Policy - Job Openings