Color DataTable rows conditionally with multiple colors across pagination and sorting.
Note: This solution is based on this example, but does not suffer from the memory leak created by markRecs
continually growing when using handleDataSourcePagination
—even cached data returned for the same records will have new Record instnaces created, and thus already known Records become stale in the markRecs
collection.
Create a colorRows
method that scans the tbody rows, evaluates the pertinent data in the corresponding Record and adds a class to the row if appropriate.
Included in the source is a convenience method inspired by Satyam's requery
function for abstracting DataSource interaction from the DataTable API.