5
votes

EDIT: code found on internet for updateTabsetPanel

I want to implement a redirect button in my Shiny application but I have never done this before, neither did I found any information on the internet/forum that can lead me into the right direction.

Basically what I am trying to do is the following: I've got a 'Load data' tab and a 'View data' tab, on the 'Load data' tab the user can select data to upload and upload this by pressing on the button "Upload". When this button is clicked, I want the application to redirect the user to the 'View data' tab, where the contents of the data and some other information gets shown.

Here is my UI.R code where the actionButton is located (the call argument):

wellPanel( 
           actionButton(inputId = "load_file", label = "Upload", icon = con("cloud-upload"))
        )

Here is my UI.R code where the tabs are located:

tabSubMenuViewData <-
  tabItem("subMenuViewData", 
          conditionalPanel(
            condition = ("input.load_file > 0"),
            tabsetPanel(type = "tab", id = "tabView",             
                tabPanel("View",DT::dataTableOutput("contents_view")),
                tabPanel("Summary", verbatimTextOutput('XSummary')),
                tabPanel("Structure", verbatimTextOutput('XStructure')),
                tabPanel("Describe", verbatimTextOutput("XDescribe")),
                tabPanel("Pivot",rpivotTableOutput("pivot_2"))     
              )                  

          )
  )

On my server.R code I am thinking in this direction:

observe({
  if (input$load_file > 0)
  updateTabsetPanel(session, "tabView ",selected = "View")
})

Any advice in the right direction is welcome.

Kind regards

1
Thanks for the advice, but doesn't seem to work in my case. I kinda got the exact same code at the moment, but using tabsetPanel instead of tabItem.wbaeckelmans
Thank you very much for your input Pork Chop, I managed to solve my issue by looking at the examples you gave!wbaeckelmans
Can you provide the solution so other users can refer to it pleasePork Chop

1 Answers

6
votes

Solution to my problem, based on Pork Chop's input:

My tabSubMenuViewData was referring to the following UI.R code, where I managed to find my needed parameters.

UI.R code:

dashboardSidebar <- dashboardSidebar(
sidebarMenu(id = "tabs",
  menuItem(tabName = "menuIntro", text = "Intro", icon = icon("sign-in")),
  menuItem(tabName = "menuManageData", text = "Manage data", icon =  icon("share-alt"),
           menuSubItem(tabName = "subMenuLoadData", text = "Load data", icon = icon("cloud-upload")),
           menuSubItem(tabName = "subMenuTransformData", text = "Transform data", icon = icon("pencil")),
           menuSubItem(tabName = "subMenuViewData", text = "View data", icon = icon("search")),
           menuSubItem(tabName = "subMenuSaveData", text = "Save data", icon = icon("cloud-download")), 
           menuSubItem(tabName = "subMenuRemoveData", text = "Remove data", icon = icon("remove")),
           menuSubItem(tabName = "subMenuHistoryData", text = "History", icon = icon("calendar")) 
  ),

Server.R code:

observeEvent(input$load_file, {
  updateTabItems(session, "tabs", "subMenuViewData")
  }
)