jquery - renderDataTable Select all cells containing value > 10 and highlight -


i'm creating datatable has user-defined number of rows & columns. loop through of cells in table (minus first column, contains names) , highlight/change css if values greater 10. shiny has great example of targeting specific column (see below). i'm assuming i'd need write sort of jquery function? i'm complete jquery newbie, gave try, and, hasn't worked (also see below). appreciated!

shiny example of targeting specific column:

rowcallback = i(   'function(row, data) {     // bold cells >= 5 in first column     if (parsefloat(data[0]) >= 5.0)       $("td:eq(0)", row).css("font-weight", "bold");   }' ) 

my failed attempt @ writing function loop through cells:

rowcallback = i('                function(row, data) {                each (i in 1:1000) {                if (parsefloat(data[i]) > 10.0)                $("td:eq(i)", row).css("color", "red");}                }') 

managed implement (without installing dt):

rowcallback = i(     'function(row, data) {         $("td", row).each(function(i) {             if (i == 0) return; // first column row names             if (parsefloat(data[i]) >= 10.0)                 $(this).css("color", "red");         });     }' ) 

Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

datatable - Matlab struct computations -