How to deselect selected input


#1

This program allows fort he selection of many files from a folder. Is there any way to deselect the selected files? For example, I select some file I do not really want to select and I need to undo the selection.

library(shiny)
library(reprex)


ui <- fluidPage(
   sidebarLayout(
     sidebarPanel(
        tags$style(type='text/css',
                   ".selectize-dropdown-content{
                 height: 1000px;
                 width: 800px;
                 background-color: #b0c4de;
                 font-size: 12px; line-height: 12px;
                }"),
       setwd("~/Development/Dir/OUT/openMS/INPUT_DATA/"),    
       
       selectInput('selectfile','Select File', choice = list.files(),multiple = TRUE),      

       textOutput('fileselected'),
       setwd("~/Development/Dir") 
       ),
     mainPanel(

    )
   )
)

server <- function(input, output){
  
  output$fileselected <- renderText({
    paste0('You have selected: ', input$selectfile)
  })

}

shinyApp(ui = ui, server = server)

#2

Hi, just to check: do you mean giving the user less choices to choose from or letting the user undo the selection? If you mean the later, they can do this by clicking something they’ve already selected again.

You can try it out yourself here ^^
http://shiny.rstudio.com/gallery/selectize-vs-select.html


#3

Check


https://www.rdocumentation.org/packages/shinyFiles/versions/0.6.2


#4

Hi sowla,

Yes. it works for single selection, but I cannot get it to work for multiple selections? Is there any thing else I should include in the selectInput statement?

Thanks


#5

Hi I’m sorry, I’m not entirely sure I understand. Did you try the example(s) in the link? If you haven’t, could try this first? :slight_smile:

In my experience, for the “No choose prompt, multiple” Select example, I can select many options and deselect them all one by one. Similarly, in the Selectize example, I can select many options and deselect by clicking the option(s) again and pressing delete. This time though, if I also press Alt or Shift at the same time, I can select multiple options before pressing delete. I use a mac, so the keys might be different if you use something else.


#6

Thank you!. I tried the examples, but I did not use any keys. I will try again.


#7

It does work in my PC selecting the item and pressing Delete. Thank you!


#8

Thanks very much for your info.


#9

This is a repeat of the previous thank you note that I cannot delete.