My question is regards to menuItem
and menuSubItem
.
As of now, clicking the MenuItem
opens a drop down menu, revealing its respective SubMenuItem
. Then, clicking the SubMenuItem
enables you to access its contents.
I am curious if it’s possible to simultaneously click a MenuItem
and:
-
Open its drop down, revealing the various
SubMenuItem
(this is the case now) -
And additionally, direct to its specific contents.
In effect, I would like each of my MenuItem
to have a kind of "Homepage", where you are immediately directed to once you click it (along with the normal presence of a drop menu).
For me, this “Homepage” feature only exists with MenuItems
that do not have SubMenuItem
. As soon as SubMenuItem
are added, clicking the MenuItem
only results in a drop down menu.
Below is some example code. I would like to be able to access "Homepages" for both MenuItems
(1 and 2) and as well access the drop menu for MenuItem 2
. As of now, clicking MenuItem 2
does not bring me to its homepage:
library(shiny)
library(shinydashboard)
# Define UI for application
ui <- dashboardPage(
dashboardHeader(title = "Shiny Dashboard"),
dashboardSidebar(
sidebarMenu(
menuItem("Menu Item 1", tabName = "menu_1"),
menuItem("Menu Item 2", tabName = "menu_2",
menuSubItem("Sub Menu Item 1", tabName = "sub_1"),
menuSubItem("Sub Menu Item 2", tabName = "sub_2")
)
)
),
dashboardBody(
tabItems(
tabItem(tabName = "menu_1",
fluidRow(
h1("Homepage 1")
)
),
tabItem(tabName = "menu_2",
fluidRow(
h1("Homepage 2")
)
),
tabItem(tabName = "sub_1",
fluidRow(
h1("Sub Menu Page 1")
)
),
tabItem(tabName = "sub_2",
fluidRow(
h1("Sub Menu Page 2")
)
)
)
)
)
# Define server logic
server <- function(input, output) {
}
# Run the application
shinyApp(ui = ui, server = server)
Any help with this issue is greatly appreciated.