Closed pssguy closed 9 years ago
Hi pssguy,
You can do this by assigning an id to the sidebarMenu
. Here's a working example :
library(shinydashboard)
library(shiny)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(
uiOutput("a"),
sidebarMenu(
menuItem("b", tabName = "tabB"),
menuItem("c", tabName = "tabC"),
id = "sbMenu"
)),
dashboardBody())
server <- function(input, output){
output$a <- renderUI({
if (input$sbMenu=="tabB") {
selectInput("test", "B", c(1:4))
} else {
numericInput("test2", "C", 50, 0, 100)
}
})
}
shiny::shinyApp(ui, server)
@Tutuchan Thanks a lot I knew there pretty much had to be a way
hi, I am facing the same problem while adding the menu subitem into the menu items. By adding the menuSubitems the tabName od the id of corresponding menuSub item is not catching. Is there a way to track or catch the menu item ID or to activate that on click with its dropdown showing simultaneously.
Hi Pssguy,
I met this problem too but I solved it by adding div() to the menuItem!
Please see the R code here:
div(id="haha", menuItem(tags$em("Download Reports",style="font-size:150%"),icon=icon("bar-chart-o"),tabName ="download"))
So in this way, your menuItem's id is "haha" and you are able to dynamically set inputs into the sidebar dependent on which menuItem has been selected!
Hopefully it is helpful for you!
Thank you!
Best regards, Jiena Gu
I tried many ways to hide/show individual menuItem()
elements but with no success yet.
I would like to be able to dynamically set inputs into the sidebar dependent on which menuItem has been selected. something like this In ui.r
in server.r
But the menuItem does not appear to have an id to reference to. Am I missing something (as usual)