Are there any out of the box solutions to have conditional formatting of HTML tables?
With conditional formatting I am more interested in having different colors as cell background depending on the value (numeric) of that or some other column (in the same table).
Something similar to what we have in excel Conditional Formating -> Color Scales -> Red Yellow Green. I want to implement that in a table that is being dynamically generated via JSP.
Are there any JavaScript/jquery or JSP solutions for this?
http://jsfiddle.net/stofke/Ya68Q/
$(function() {
$('tr > td:odd').each(function(index) {
var scale = [['vPoor', 10], ['poor', 50], ['avg', 250], ['good', 1250], ['vGood', 6250]];
var score = $(this).text();
for (var i = 0; i < scale.length; i++) {
if (score <= scale[i][1]) {
$(this).addClass(scale[i][0]);
}
}
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With