1

我正在尝试修改搜索栏,Shiny例如我们可以在 中键入内容或他的标题pickerInput

代码示例:

library(shiny)
library(shinyWidgets)

ui <- fluidPage(
  pickerInput(
    inputId = "pick", label = "Selected", 
    choices = split(c("Choice 1" = "Value 1", "Choice 2" = "Value 2"), c("First", "Other")), 
    multiple = TRUE,
    options = list( `live-search` = TRUE)
  )
)

server <- function(input, output, session) {
}

shinyApp(ui, server)

这种方式是想输入文本Choice 2Other在搜索栏中获取第二个输入。但研究Other没有给出任何结果。

可能会接受隐藏标题但可以对其进行搜索的答案。

任何帮助将不胜感激。

4

1 回答 1

1

如果您安装 {shinyWidgets} 的开发版本(v0.4.9.940,即将在 CRAN 上),您可以传入一个插槽tokenschoicesOpt声明一些在实时搜索中使用的关键字:

library(shiny)
library(shinyWidgets)

ui <- fluidPage(
  pickerInput(
    inputId = "pick", label = "Selected", 
    choices = split(c("Choice 1" = "Value 1", "Choice 2" = "Value 2"), c("First", "Other")), 
    multiple = TRUE,
    options = list( `live-search` = TRUE),
    choicesOpt = list(
      tokens = c("first choice 1", "other choice 2")
    )
  )
)

server <- function(input, output, session) {
}

shinyApp(ui, server)
于 2019-11-17T21:05:53.430 回答