我正在开发一个闪亮的应用程序shinyWidgets
包来做我的selectInput
. 对于导致一些错误的输入变量,我有许多模式。我减小了picker
(size 参数)的大小,如果可能的话,只显示 10 个变量的第一个选项并激活 liveSearch 选项。但似乎不起作用...
library(shiny)
library(shinyWidgets)
ui <- fluidPage(
pickerInput(
inputId = "somevalue1",
label = "somevalue1",
choices = NULL,
multiple = TRUE,
selected = NULL,
options = list(
`actions-box` = TRUE,
size = 10,
`live-search` = TRUE
)
),
pickerInput(
inputId = "somevalue2",
label = "somevalue2",
choices = NULL,
multiple = TRUE,
selected = NULL,
options = list(
`actions-box` = TRUE,
size = 10,
`live-search` = TRUE
)
)
)
server <- function(input, output, session) {
observe({
updatePickerInput(
session = session,
inputId = "somevalue1",
choices = 1:1000
)
})
observe({
if (!is.null(input$somevalue1))
choices <- which(input$somevalue1 %in% 1:1000)
else
choices <- 1:1000
updatePickerInput(
session = session,
inputId = "somevalue2",
choices = choices
)
})
}
shinyApp(ui, server)
在此示例中,我只想显示前 10 个值(但如果我搜索它们可以找到其他值)。我想去掉滚动条,可以吗?