0

I am trying to use update my Shiny Dashboard Sidebar based on the tab selected in the Main body. So when tab "Overall" is selected then this should display the menu items in Conditional Panel 1 (TA.Name1,TA.Name2), and when tab "Other" is selected then the sidebar displays the menu items for conditional panel 2. Data is bellow:

ui <- dashboardPage(
  dashboardHeader(),
  dashboardSidebar(
    conditionalPanel(condition="input.conditionedPanels==1", sidebarMenu(width=150,
      menuItem("TA.Name1", tabName = "TA1")),
      menuItem("TA.Name2", tabName = "TA2"))),
    conditionalPanel(condition="input.conditionedPanels==2",sidebarMenu(width=150,
      menuItem("EA.Name1", tabName = "EA1")),
      menuItem("EA.Name2", tabName = "EA2"))),             
  dashboardBody(
     tabsetPanel(
        tabPanel("Overall",value=1,fluidRow(
          column(3,selectInput("PACO", h5("PACO"), levels(OA$PACO)))),
          tabItems(
            tabItem(tabName = "TA1","TA1"),fluidRow(
               box(title="TA.Name1,dygraphOutput("TA1.data")),
               box(title="TA.Name2,dygraphOutput("TA2.data")))),
            tabItem(tabName = "TA2","TA2")
    )),
        tabPanel("Other",value=2,fluidRow(
          column(3,selectInput("CV", h5("CV"), levels(OA$CV)))),
          tabItems(
            tabItem(tabName = "EA1","EA1"),fluidRow(
               box(title="EA.Name1,dygraphOutput("EA1.data")),
               box(title="EA.Name2,dygraphOutput("EA2.data")))),
            tabItem(tabName = "EA2","EA2")
    ))))
user5316628
  • 357
  • 2
  • 11

1 Answers1

0

Your Example Code is not good, i think You should have a look at this feed: http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

I had to simplify Your code to actually find solution...

Have a look at it:

library(shiny)
library(shinydashboard)

ui <- dashboardPage(
  dashboardHeader(),
  dashboardSidebar(
      sidebarMenu(id="tabs",
                  sidebarMenuOutput("menu"))),
  dashboardBody(
  tabsetPanel(id="tabs2",
  tabPanel("Overall",value=1),
  tabPanel("Other",value=2))))

server <-  function(input, output, session) {

  output$menu <- renderMenu({
    if (input$tabs2 == 1 ) {
    sidebarMenu(
      menuItem("TA.Name1", tabName = "TA1"),
      menuItem("TA.Name2", tabName = "TA2"))}
    else{
      sidebarMenu(
        menuItem("EA.Name1", tabName = "EA1"),
        menuItem("EA.Name2", tabName = "EA2"))
    }
  })
  }

shinyApp(ui = ui, server = server)

It should do what You want -- > reactive sidebarMenu

Mal_a
  • 3,670
  • 1
  • 27
  • 60