datatables - How to set color for table rows based on column value in jQuery data table -


i using jquery datatables.i have data follows

column1 column2 column3 -----------------------  aaa    bbb     ccc  aaa    ggg     yyy  bbb    ooo     lll 

now in column1 first 2 rows have same value aaa.i want apply color rows.and color third row.like have 30 records.is possible this.if possible how can this.i using jquery data tables.thanks in advance..

use fnrowcallback (or newer rowcallback) achieve this

$('#example').datatable({     "fnrowcallback": function( nrow, adata, idisplayindex, idisplayindexfull ) {         switch(adata[0]){             case 'aaaa':                 $(nrow).css('color', 'red')                 break;             case 'bbbb':                 $(nrow).css('color', 'green')                 break;             case 'cccc':                 $(nrow).css('color', 'blue')                 break;         }     } }); 

demo: fiddle


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -