I'm doing some tests with shiny and I've created a data.frame
for the messages as if it were an inbox .
I show the messages both in notifications and in a library table DT
. I would like that when you click on them in the table change their value read to TRUE
I leave you what I've been trying:
Data frame messages
from <- c("A","B","C")
content <- c("Mensaje 1","Mensaje2","Mensaje leido")
leido <- c(FALSE,FALSE,TRUE)
messages <- data.frame(from,content,leido)
DT :: datatableoutput of messages
output$tablaMensajes <- DT::renderDataTable({
messages
})
Message notifications
output$mensajes <- renderMenu({
if(! is.null(input$tablaMensajes_rows_selected)){
s<-input$tablaMensajes_rows_selected
messages[s,"leido"] <- TRUE
}
msgs <- apply(messages[which(messages$leido == FALSE),], 1, function(row) {
messageItem(from = row[["from"]], message = row[["content"]],href = paste0("javascript:mensaje('",row[["content"]],"')"))
})
dropdownMenu(type = "messages", .list = msgs)
})
It is in the message notifications where I check if it has been pressed and if so it changes its value read to TRUE
, the problem is that it is not saved in the data frame as TRUE
.