Reputation: 197
I'm trying to highlight a specific row in my dataTable and change the font colour has well.
I've managed to highlight the row and change the font colour. However, the font colour changes for the entire table not only for the specified row.
Below is a reproducible code with my problem. As you can see the specified row is highlighted with no problem but if you uncomment the line #color = 'white',
you will see what is my problem.
library(DT)
library(tibble)
mtcars <- rownames_to_column(mtcars, "carNames")
datatable(mtcars, options = list(dom = 't')) %>%
formatStyle('carNames',
target='row',
#color = 'white',
backgroundColor = styleEqual('Valiant','red'))
I've tried moving the colour argument around but it does not work. Any pointers will be very much appreciated.
Cheers
Upvotes: 1
Views: 1446
Reputation: 6964
Just use the same logic for the font color
datatable(mtcars, options = list(dom = 't')) %>%
formatStyle('carNames',
target='row',
color = styleEqual('Valiant','white'),
backgroundColor = styleEqual('Valiant','red'))
Upvotes: 4