R发光选择器输入搜索的命名选择标题和内容

问题描述 投票:1回答: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的研究没有结果。

可以隐藏标题但可以搜索标题的答案。

任何帮助将不胜感激。

r shiny bootstrap-select selectinput pickerinput
1个回答
1
投票

如果您安装了{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)
© www.soinside.com 2019 - 2024. All rights reserved.