选择显示所有项目的下拉菜单

问题描述:

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

I have a small problem which I can't resolve. I suppose that the solution is very easy and I don't have a lot of knowledge in java language. Here is a small example:

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为了做出选择时,我不想显示列表的前七个元素,而是要显示列表的所有元素。
谢谢。

When the user clicks on the first selectInput in order to make a choice, instead of showing the first seven elements of the list, I would like to show all the elements of the list. Thanks.

您可以使用CSS tags $ style(type ='text / css', .selectize-dropdown-content {max-height:1000px!important;})来做到这一点

You could use css tags$style(type='text/css', ".selectize-dropdown-content {max-height: 1000px !important; }") to do that

类似这样的东西:

ui <- (fluidPage(
  tags$style(type='text/css', ".selectize-dropdown-content {max-height: 1000px !important; }"), 
  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;
                      }
                      '
      )
      )
      )
      )
      ))

您将获得: