【发布时间】:2022-02-24 11:15:33
【问题描述】:
我在下面分享了代码。 我有多个选项卡,其中一个选项卡有一个 selectizeInput,其中包含 50,000 个唯一值的列表。 因此,正如这里https://shiny.rstudio.com/articles/selectize.html 所建议的那样,我在服务器端使用它。 由于某些原因,包含 selectizeInput 元素的页面 Dashboard 2 没有反应。无论我在那里输入什么,该字段都是空的。 考虑到我非常大的闪亮应用程序,我的代码使用不同的 R 文件构建。 但是,为了复制问题,您只需要两个文件。第一个文件名为“app.R”,包含以下代码:
ui <- dashboardPage(
title = "Title test",
dashboardHeader(title = "Dashboard header"),
dashboardSidebar(
includeCSS("www/styles.css"),
sidebarMenu(
menuItem('Retail1', tabName = "tab1", icon = icon("th"),
menuItem('Dashboard2', tabName = 'retail_dashboard1')
),
menuItem('Retail2', tabName = "tab2", icon = icon("th"),
menuItem('Dashboard2', tabName = 'retail_dashboard2')
)
)
),
dashboardBody(
tabItems(
tabItem(tabName = "retail_dashboard2",
uiOutput("ui_retail_dashboard2") )
)
)
)
server <- function(input, output, session) {
source("Page_retail_dash2.R", local=T)
shiny::updateSelectizeInput(session=session, inputId ='element_with_list_of_cities', choices = rownames(mtcars), server = TRUE )
}
cat("\nLaunching 'shinyApp' ....")
shinyApp(ui, server)
第二个文件名为“Page_retail_dash2.R”,包含以下简单代码:
output$ui_retail_dashboard3 <- renderUI({
tabsetPanel(type = "tabs",
tabPanel("Dashboard 3",
h3("Test"),
fluidRow(
column(2,
selectizeInput(inputId = "element_with_list_of_cities_dash3",
label = "Cities",
choices = NULL,
selected = NULL,
multiple = TRUE # allow for multiple inputs
,options = list(create = FALSE, maxOptions = 1000) # if TRUE, allows newly created inputs))
))
)
)
)
})
如果您只是复制并粘贴我的代码,您应该能够复制该问题。我还在这里附上我看到的我运行我的应用程序。 您可能会问为什么第一个选项卡是空的。在我的应用中,它不是空的,它有一些表,但你不需要它来复制这个问题。
【问题讨论】:
-
对我来说还不清楚。您能否详细说明一下。
-
当然,应该显示带有自动完成功能的值列表的框只是空的。