The below application is updating the url based on row selected in the DT table and the selected tab. But what happens is, when the user copy paste the url in another tab, it is not opening the specific tab, instead it is opening the default page (url : http://127.0.0.1:XXXX/?tab1)
library(shiny)
library(readxl)
library(dplyr)
library(xtable)
library(shinyWidgets) ## for picker input
library(shinydashboard)
library(DT)
library(tidyverse)
library(shinycssloaders)
library(plotly)
library(htmlwidgets)
library(sparkline)
library(data.table)
require(reshape2)
library(glue)
ui <- shinyUI(navbarPage(
"title",id = "inTabset",selected = "Summary",
tabsetPanel(id = "tabs",
# tabPanel(
# "Read me",tags$head(tags$link(rel = "stylesheet", type="text/css", href="style.css"))
# ),
tabPanel(
"Summary",
DT::dataTableOutput("tab")))
)
)
server <- function(input, output, session) {
output$tab <- DT::renderDataTable({
datatable(iris,selection = 'single')
})
observeEvent(input$tab_rows_selected, {
insertTab(inputId = "tabs",
tabPanel(paste0("tab",input$tab_rows_selected),
selectInput(paste0("tab",input$tab_rows_selected),input$tab_rows_selected,choices = c(1,input$tab_rows_selected))
),select = TRUE
)
})
observe({
query <- getQueryString()
print(names(query))
updateQueryString(paste0("?",input$tabs), mode = "push")
})
}
shinyApp(ui, server)