Reputation: 93
I am getting a weird problem with shiny dashborad, I've been unable to select back a menu Item that I already selected once.
Please find below my code which is so basic, I would appreciate so much your help if you notice anything :
ui <-dashboardPage( dashboardHeader(title = "Dashborad" ),
dashboardSidebar(
menuItem("A", tabName = "A", icon = icon("users")),
menuItem("B", tabName = "B",icon = icon("hand-holding-usd"),
menuItem("B1", tabName = "b1", icon = icon('line-chart')),
menuItem('B2', tabName = "b2", icon = icon('line-chart')),
menuItem('B3', tabName = "b3", icon = icon('line-chart'))
),
menuItem("C", tabName = "c", icon = icon("shopping-cart")),
menuItem("D", tabName = "d", icon = icon("ellipsis-h"))
),
dashboardBody(
tabItems( tabItem(tabName = "A",h2("AAAAAAAAAAAa")),
tabItem(tabName = "b1",h2("BBBBBBBBBBBb1111")),
tabItem(tabName = "b2",h2("BBBBBBBBBBBBBb222")),
tabItem(tabName = "b3",h2("BBBBBBBBBBBB3333")),
tabItem(tabName = "c",h2("CCCCCCCCCCCCccc")),
tabItem(tabName = "d",h2("DDDDDDDDDDDDDdd"))
)))
server <- function(input, output,server) {}
shinyApp(ui, server)
Upvotes: 1
Views: 187
Reputation: 6954
You missed to wrap the menuItem()
s in sidebarMenu()
. See the description of dashboardSidebar()
:
A dashboardSidebar can contain a sidebarMenu. A sidebarMenu contains menuItems, and they can in turn contain menuSubItems.
library(shinydashboard)
ui <-dashboardPage( dashboardHeader(title = "Dashborad" ),
dashboardSidebar(
sidebarMenu(
menuItem("A", tabName = "A", icon = icon("users")),
menuItem("B", tabName = "B",icon = icon("hand-holding-usd"),
menuSubItem("B1", tabName = "b1", icon = icon('line-chart')),
menuSubItem('B2', tabName = "b2", icon = icon('line-chart')),
menuSubItem('B3', tabName = "b3", icon = icon('line-chart'))
),
menuItem("C", tabName = "C", icon = icon("shopping-cart")),
menuItem("D", tabName = "D", icon = icon("ellipsis-h"))
)),
dashboardBody(
tabItems( tabItem(tabName = "A",h2("AAAAAAAAAAAa")),
tabItem(tabName = "b1",h2("BBBBBBBBBBBb1111")),
tabItem(tabName = "b2",h2("BBBBBBBBBBBBBb222")),
tabItem(tabName = "b3",h2("BBBBBBBBBBBB3333")),
tabItem(tabName = "C",h2("CCCCCCCCCCCCccc")),
tabItem(tabName = "D",h2("DDDDDDDDDDDDDdd"))
)))
server <- function(input, output,server) {}
shinyApp(ui, server)
Upvotes: 1