Force no default selection in selectInput()

前端 未结 6 1147
别跟我提以往
别跟我提以往 2021-02-01 02:17

The Shiny documentation mentions that for selectInput():

selected The value (or, if none was supplied, the title) of the naviga

6条回答
  •  时光说笑
    2021-02-01 02:44

    Faced a similar issue. The solution I found is based of @MKa's answer. You do not want to set multiple=T if your code can't handle multiple values. What I suggest is:

    selectInput("molecule",
                "Select Molecule:",
                choices = c("",as.character(mtrl_name)),
                selected = NULL,
                multiple = F
               ) 
    

    And to retrieve the value selected:

    if(!is.null(input$molecule))
    {
      if(nchar(input$molecule)>1)
      {
        #do your thing..
      }
    }
    

    Fixed my problem. Let me know if you found a better solution.

提交回复
热议问题