【问题标题】:selectizeInput() in R Shiny doesn't allow typing until I have selected and deleted an entry在我选择并删除一个条目之前,R Shiny 中的 selectizeInput() 不允许输入
【发布时间】:2021-10-09 18:21:44
【问题描述】:

我的 ui 中有一个 selectizeInput() 框,在我的服务器函数中有服务器端 selectize updateSelectizeInput()。我希望用户能够在输入框中输入建议,但在我选择并删除一个条目之前,它不会让我输入任何内容。在我的应用程序的完整版中,有数千个选项,因此需要进行服务器端更新,并且滚动浏览选项是不切实际的。我隔离了我的应用程序的那部分,在下面输入。

ui <- fluidPage(
  selectizeInput(inputId = 'cwdsearchscanid', label = 'ScanID Lookup',
                 choices = NULL,
                 selected = NULL,
                 options = list(placeholder = 'Enter ScanID')
  )
)

server <- function(input, output, session) {
  updateSelectizeInput(session, 'cwdsearchscanid', choices = c('', '1234', '2345', '3456', '4567', '5678', '6789', '7890', '8901', '9012', '0123'), server = T)
}

shinyApp(ui = ui, server = server)

【问题讨论】:

    标签: r shiny server-side selectize.js


    【解决方案1】:

    你应该使用selected = character(0),如下所示

    updateSelectizeInput(session, 'cwdsearchscanid',
                         choices = c('', '1234', '2345', '3456', '4567', '5678', '6789', '7890', '8901', '9012', '0123'),
                         selected = character(0),
                         server = TRUE)
      
    

    【讨论】:

    • 这对我帮助很大!谢谢。
    猜你喜欢
    • 1970-01-01
    • 2017-02-08
    • 1970-01-01
    • 2018-11-08
    • 2017-12-29
    • 2021-06-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多