I am using renderui in R Shiny to generate a checkbox, I'm wondering how to add a 'select all' option, which can be used to check and uncheck all the boxed. here is an example of the checkbox I want
This link shows how to add the 'select all' button, but is not for the checkbox inside renderui. Currently the method I used is
output$trmt_id <- renderUI({
if(is.null(ep_info())) {
return()
}
trmt_ids <- unique(ep_info()$TRMT_ID)
# add 'selected = ' to pre-select ctrl
checkboxGroupInput("input_trmt_id", "Choose Treatment ID (Include Control)", choices = c(trmt_ids, 'All'))})
observeEvent(input$input_trmt_id, {
if (input$input_trmt_id %in% 'All') {
updateCheckboxGroupInput(session, "input_trmt_id", "Choose Treatment ID (Include Control)", choices = c(unique(ep_info()$TRMT_ID), 'all'), selected = unique(ep_info()$TRMT_ID))
}})
But the problem of this piece of code is user cannot unselect all boxed just by clicking 'all' again.
Do you have some better ideas? Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire