【发布时间】:2020-01-19 05:50:25
【问题描述】:
我想通过按第一个仪表板上的操作按钮打开第二个仪表板。我可以使用下面的代码做到这一点,但仪表板是相互连接的。例如。如果我关闭第二个仪表板上的侧边栏,第一个仪表板上的侧边栏也会关闭。
这是 server.R 文件:
function(input, output, session) {
# some more code
# react to clicking on button show2
observeEvent(input$show2, {
# here is some more code
showModal(settngsModal())
})
settngsModal <- function() {
modalDialog(
withTags({
dashboardPage(
dashboardHeader(
title = "Second Dashboard"
),
dashboardSidebar(
sidebarMenu(
menuItem("Widgets", tabName = "widgets", icon = icon("th"))
)),
dashboardBody(
tabItem(tabName = "widgets",
h1("Widgets tab content")
)
)
)
}),
title = "Settings",
fade = TRUE)
}
}
这是 ui.R 文件:
dashboardPage(
dashboardHeader(
title = "First dashboard"
),
dashboardSidebar(collapsed = TRUE,sidebarMenu()),
dashboardBody(),
h1('Headline'),
actionButton("show2", "Show second dashboard", size = 'lg')
)
)
是否可以有一个“独立”的仪表板?
甚至可能有两个可以并排使用的仪表板(因为现在第二个仪表板是一个弹出窗口,而第一个仪表板只有在第二个仪表板关闭时才能使用)?
【问题讨论】:
标签: r shiny shinydashboard action-button