我们有没有办法提供可用的选项,同时在shiny中使用类似于shiny selectinput选项的textInput?
也就是说,如果用户键入一个字母或字符,则必须提供该字母或字符内的所有可用选项。因为我有很多选项,选择not会变慢,不是一个好的输入选项。因此,我选择了textInput。
任何建议都会很有帮助!
谢谢
发布于 2016-06-16 18:59:28
可以将selectInput与参数multiple = TRUE一起使用
selectInput(inputId, label, choices, multiple = TRUE)这将输出一个文本框而不是下拉框,当用户开始键入时,字母中的所有可用选项都将被过滤。
Create a select list input control
Example
发布于 2016-09-04 19:00:46
使用DT,您可以做一些奇特的事情。下面是一个示例,其中该表列出了包含您键入的文本的所有选项。如果单击表单元格,则文本输入将随表单元格的文本一起更新。您还可以使用表的搜索字段。
library(shiny)
shinyApp(
ui = fluidPage(textInput("text", "Please input text:"),
DT::dataTableOutput('tbl')),
server = function(session, input, output) {
# all your choices for the textfield go into "text" column
allData <- data.frame(ID = '', text = c(paste0("Text",1:50)))
# table with only the texts that contain input$text
output$tbl = DT::renderDataTable(
allData[grep(input$text, allData$text), ],
selection = 'none',
rownames = FALSE,
options = list(searchHighlight=T)
)
# fill textInput after Click in Table
observeEvent(input$tbl_cell_clicked, {
info <- input$tbl_cell_clicked
if (is.null(info$value) || info$col != 1) return()
else {
updateTextInput(session, "text", value = info$value)
}
})
}
)

发布于 2017-02-03 17:02:51
选择not有点慢,不是一个好的输入选项
在这种情况下,具有多项选择的selectInput是最好的选择。通过将selectInput移动到服务器中,可以很容易地管理缓慢的加载。
只需输入ui.R即可
selectizeInput(inputId=..., label=..., choices = NULL, multiple = TRUE)在server.R中
server <- function(input, output, session) {
updateSelectizeInput(session = session,inputId =...,choices=..., server = TRUE)}现在您应该不会遇到任何加载速度慢的问题。
https://stackoverflow.com/questions/37430387
复制相似问题