Have been struggling with the very same issue posted here for a while. It was not solved and the stackoverflow links is broken.
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 …
Links to Stackoverflow are broken. Is this even possible in Shiny? Basically clicking on a MenuItem that has selectInput items and be able to link it via tabName to a tabItem. So far I'm only able to get it to work for MenuItems that do not have sub-elements.
Any ideas?
You can at least make it go to the first submenuitem of the clicked menuitem
library(shiny)
library(shinydashboard)
# Define UI for application
ui <- dashboardPage(
dashboardHeader(title = "Shiny Dashboard"),
dashboardSidebar(
sidebarMenu(
id = "mytabitems",
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, session) {
observe({
cat("input$mytabitems ", input$mytabitems, "\n")
cat("input$menu_1 ", input$menu_1, "\n")
cat("input$menu_2 ", input$menu_2, "\n")
cat("input$sub_1 ", input$sub_1, "\n")
cat("input$sub_2 ", input$sub_2, "\n")
})
observeEvent(input$sidebarItemExpanded, {
if (input$sidebarItemExpanded == "MenuItem2") {
print("updating tab items")
updateTabItems(session, "mytabitems", "sub_1")
}
})
}
# Run the application
shinyApp(ui = ui, server = server)
system
Closed
August 25, 2020, 10:26am
3
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.