java - 选择显示所有元素的下拉列表

标签 java css shiny dropdown selectize.js

我有一个我无法解决的小问题。我认为解决方案非常简单,而且我对 Java 语言的了解不多。 这是一个小例子:

library(shiny)

ui <- (fluidPage(
  sidebarLayout(
    sidebarPanel(
      selectInput("userInput","Select User", c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21),
                  selected=1),
      selectInput("LongInput", "Long Strings", c("This is a long long string that is long.",
                                                 "This is a long long string that is longer."))
    ),

    # allows for long texts to not be wrapped, and sets width of drop-down
    tags$head(
      tags$style(HTML('
                      .selectize-input {
                      white-space: nowrap;
                      }
                      #LongInput + div>.selectize-dropdown{
                      width: 660px !important;
                      }
                      #userInput + div>.selectize-dropdown{
                                            width: 357px !important; maxItems: 21;
                      }
                      '
              )
      )
      )
      )
      ))

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

shinyApp(ui, server)

当用户单击第一个 selectInput 以进行选择时,我不想显示列表的前七个元素,而是显示列表的所有元素。 谢谢。

最佳答案

我认为 shinyWidgets 包是您所需要的。它有一个 pickerInput 将显示所有的选择

#install.packages("shinyWidgets")
library(shiny)
library(shinyWidgets)

ui <- fluidPage(
  sidebarLayout(
    sidebarPanel(
      pickerInput("userInput", label = "Select User", choices = 1:21, options = list(style = "btn-primary")),
      selectInput("LongInput", "Long Strings", c("This is a long long string that is long.",
                                                 "This is a long long string that is longer."))
    ),mainPanel()
  )
)

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

shinyApp(ui, server)

enter image description here

关于java - 选择显示所有元素的下拉列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46906477/

相关文章:

java - 值没有从另一个类返回

java - 我可以使用 Google Plus 登录来验证我在 App Engine 中的 OAuth 方法吗?

java - Netty:MessageToMessageEncoder 并转换为 ByteBuf

html - div居中技术/问题

jquery - Internet Explorer 7 css js 表格列显示错误

html - Ruby on Rails ajax 弹出消息

在 Shiny 应用程序中调整嵌入图像的大小

Java, boolean 值可以从 boolean 值赋值,反之亦然吗?

r - R Shiny 中的自动 GUI 生成

user-interface - 单击 Shiny 的操作按钮转到 flexdashboard 的另一页