shiny.semantic
shiny.semantic copied to clipboard
Feature request: add a 'Select all' button in `multiple_checkbox()`
This feature could be implemented as in #378 , but this approach does not always work (in modules, renderUI
, ...).
Workaround, adding a toggle or checkbox In the link: https://stackoverflow.com/c/appsilon/questions/214/219#219
library(shiny.semantic)
library(shiny)
two_list<-list(as.character(c(10,20,30,40,50,60) ) )
ui <- semanticPage(
uiOutput("servicetypeUI1")
,shiny.semantic::toggle(input_id="allNoneInput"
, label = "All/None"
, is_marked = TRUE
, style = NULL)
)
server <- function(input, output, session) {
observeEvent(input$allNoneInput,{
if(input$allNoneInput ) {
update_multiple_checkbox(session, input_id="type"
, selected = as.character(seq_along(
two_list[[1]]) )
)
} else {
update_multiple_checkbox(session, input_id="type"
, selected = list())
}
})
output$servicetypeUI1 <- renderUI({
tagList(
div(
strong("Service type")
)
,multiple_checkbox(
input_id = "type",
label = "",
choices = two_list[[1]],
choices_value = as.character(seq_along(two_list[[1]]) ),
selected = as.character(seq_along(two_list[[1]]) )
)
)
})
}
shiny::shinyApp(ui, server)