我正在尝试修改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 2
或Other
并获得第二个输入。但是对Other
的研究没有结果。
可以隐藏标题但可以搜索标题的答案。
任何帮助将不胜感激。
如果您安装了{shinyWidgets}的开发版本(v0.4.9.940,不久将在CRAN上运行,则可以在tokens
中传递插槽choicesOpt
来声明一些实时搜索中使用的关键字:
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)