Externally link to specific tabPanel in Shiny App

后端 未结 2 710
旧时难觅i
旧时难觅i 2021-01-03 10:44

It\'s possible to use anchor links in flat Shiny apps relatively easily - https://stackoverflow.com/a/28605517/1659890.

However, is it possible for an external link

2条回答
  •  隐瞒了意图╮
    2021-01-03 11:16

    I found the other answer a little difficult to follow so I created the example below. To navigate to the Data Availability tab, place "?a=b" to at the end of your url. For example if hosting the app on port 7436 the following link will take you directly to the Data Availability page. http://127.0.0.1:7436/?a=b

    library(shinydashboard)
    library(shiny)
    ui <- dashboardPage(
      dashboardHeader(),
      dashboardSidebar(
        sidebarMenu(id = "container",
          menuItem("Channels", tabName = "lt_channels"),
          menuItem("Data Availability", tabName = "data_avail")
        )),
      dashboardBody(
        tabItems(
          tabItem(tabName = "lt_channels",
                  h1("Test Fail")),
          tabItem(tabName = "data_avail",
                  h1("Test Pass"))
        )
      )
    )
    
    
    
    server <- function(session, input, output){
      observe({
        query <- parseQueryString(session$clientData$url_search)
        query1 <- paste(names(query), query, sep = "=", collapse=", ")
        print(query1)
        if(query1 == "a=b"){
          updateTabItems(session, inputId = "container", selected = "data_avail")
        }
      })
    }
    shinyApp(ui = ui, server = server)
    

提交回复
热议问题