I am trying to use an editable DT table in shiny.
The cells should be highlighted according to some rules (in this instance, the cells of V1 are highlighted when "new" equals 0 or 1).
However, I cannot make it work dynamically: when the user edits the values, the highlighted cells remain unchanged. Should I use a reactive and how?
Here is my short code:
library(shiny)
library(DT)
shinyApp(
ui = fluidPage(DTOutput('tbl')),
server = function(input, output) {
df = as.data.frame(cbind(matrix(round(rnorm(50), 3), 10)))
df$new=rownames(df)
output$tbl= renderDataTable({
datatable(df, editable = T)%>%
formatStyle(
'V1', 'new',
backgroundColor = styleEqual(c(0, 1), c('gray', 'yellow'))
)
})
Thank you for your help!
PS: I asked that also on SO: