选择显示所有项目的下拉菜单 [英] Selectize dropdown showing all items

查看:103
本文介绍了选择显示所有项目的下拉菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小问题无法解决。我想该解决方案非常简单,而且我对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;
                      }
                      '
      )
      )
      )
      )
      ))

您将获得:

这篇关于选择显示所有项目的下拉菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆