Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: add a 'Select all' button in multiple_checkbox() #379

Open
u9090 opened this issue Jul 22, 2021 · 1 comment
Open

Feature request: add a 'Select all' button in multiple_checkbox() #379

u9090 opened this issue Jul 22, 2021 · 1 comment

Comments

@u9090
Copy link

u9090 commented Jul 22, 2021

This feature could be implemented as in #378 , but this approach does not always work (in modules, renderUI, ...).

@u9090 u9090 changed the title Feature request: add a 'Select/Deselect all' button in multiple_checkbox() Feature request: add a 'Select all' button in multiple_checkbox() Jul 22, 2021
@fernandoroa
Copy link

fernandoroa commented Mar 7, 2022

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants