0
我有一個儀表板,應該可以幫助用戶跟蹤雜事列表。這些雜事在sidebarMenu
中列爲menuSubItem
。因此,如果創建了與雜項相對應的文件,我想要在menuSubItem
旁邊放置一個支票圖標。動態菜單:帶有子項目的ID項
我有一個很難理解爲什麼那些menuSubItem
拭目以待,直到我點擊了test
,然後再home
被渲染。我試圖打印出input$test_subitems
,似乎我無法跟蹤時test
被選中。
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
skin = "blue",
dashboardHeader(title = "Dynamic Menu"),
dashboardSidebar(
sidebarMenu(
id = "sidebarMenu",
menuItem("Home", tabName = "home", icon = icon("home")),
menuItem("Item with subitems", tabName = "test",
uiOutput("test_subitems"))
)
),
dashboardBody(id = "dashboardBody")
)
server <- shinyServer(function(input, output, session) {
observe(cat('1:', input$sidebarMenu, '\n'))
output$test_subitems <- renderUI({
print(input$sidebarMenu)
tabs <- c("st1","st2")
lapply(tabs, function(tab) {
menuSubItem(icon = NULL, paste('Test:', tab), tabName = tab)
})
})
session$onSessionEnded(stopApp)
})
shinyApp(ui, server)