导航到ShinyDashboard中特定的侧边栏菜单项?
问题描述:
(闪亮谷歌群组的交叉帖子,https://groups.google.com/forum/#!topic/shiny-discuss/CvoABQQoZeE)导航到ShinyDashboard中特定的侧边栏菜单项?
如何导航到ShinyDashboard中的特定边栏菜单项?
sidebarMenu(
menuItem("Menu Item 1")
menuItem("Menu Item 2")
)
即如何在“Menu Item 1”页面上放置一个按钮,该按钮将链接到“Menu Item 2”?
为制表我用updateTabsetPanel功能的导航:
observeEvent(input$go,{
updateTabsetPanel(session, "tabset1", selected = "Step 2")
})
我相信我应该能够使用类似的功能导航至工具栏菜单,但我不知道那是什么。
任何指针十分赞赏
感谢
伊恩
答
这是你在找什么?注意,例如从Change the selected tab on the client
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(title = "Simple tabs"),
dashboardSidebar(
sidebarMenu(id = "tabs",
menuItem("Menu Item 1", tabName = "one", icon = icon("dashboard")),
menuItem("Menu Item 1", tabName = "two", icon = icon("th"))
)
),
dashboardBody(
tabItems(
tabItem(tabName = "one",h2("Dashboard tab content"),actionButton('switchtab', 'Switch tab')),
tabItem(tabName = "two",h2("Widgets tab content"))
)
)
)
server <- function(input, output, session) {
observeEvent(input$switchtab, {
newtab <- switch(input$tabs, "one" = "two","two" = "one")
updateTabItems(session, "tabs", newtab)
})
}
shinyApp(ui, server)
采取准确,谢谢。我不确定如何为sidebarMenu设置ID – Iain