'How to display content in nested tab menu structure (3 levels)?
In order to achieve a menu item, with two sub-levels, I wrote the code below. As you can see, the text in the subMenuItems is getting displayed properly. However, when the top level tab is selected, I want to display an empty page and on the second level (menuItem inside menuItem), I want to display the text "second".
What do I need to change, in order to get there?
# shiny lib
library(shiny)
library(shinythemes)
library(shinydashboard)
# UI
ui <- dashboardPage(
dashboardHeader(title = "Test"),
dashboardSidebar(
sidebarMenu(id = "tabs",
menuItem("Top_Level", tabName = "first",
icon = icon("chart-line"),
menuItem("Second_level",
tabName = "second",
menuSubItem("Summary",
tabName = "third1",
),
menuSubItem("Details",
tabName = "third2",
)
)
)
)
),
dashboardBody(
tabItems(
tabItem(tabName = "first",
mainPanel(width = 100,
fluidPage(fluidRow(
p("")
)
)
)
),
tabItem(tabName = "second",
mainPanel(width = 100,
fluidPage(fluidRow(
p("second")
)
)
)
),
tabItem(tabName = "third1",
mainPanel(width = 100,
fluidPage(fluidRow(
p("third.1")
)
)
)
),
tabItem(tabName = "third2",
mainPanel(width = 100,
fluidPage(fluidRow(
p("third.2")
)
)
)
)
)
)
)
# server
server <- function(input, output, session) {
renderText(output$first)
renderText(output$second)
renderText(output$third1)
renderText(output$third2)
}
runApp(list(ui = ui, server = server), launch.browser = TRUE)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
