Let see the following application.
When a user sees a table and clicks on the hyperlink "B" I would like to go into "Letters" and have selected the value "B" there.
How it can be done?
library(shiny)
library(DT)
library(data.table)
server <- function(input, output, session) {
output$uo_selector <- renderUI({
selectizeInput(
'si_letters', 'Letters',
choices = c("A", "B", "C"),
multiple = FALSE, selected = "A")
})
df_table <- reactive({
data.table(
letters = c(
paste0("<a href='Go to selector with value A'>", "A", "</a>"),
paste0("<a href='Go to selector with value B'>", "B", "</a>"),
paste0("<a href='Go to selector with value C'>", "C", "</a>")),
numbers = c(1, 2, 3)
)
})
output$dt_table <- renderDataTable(
df_table(), escape = FALSE, options = list(pageLength = 5))
}
ui <- fluidPage(
navbarPage('TEST',
tabPanel("Table",
fluidPage(
fluidRow(dataTableOutput("dt_table")))),
tabPanel("Letters",
fluidPage(
fluidRow(uiOutput("uo_selector"))))
)
)
# Run the application
shinyApp(ui, server)
Thanks
CodePudding user response:
Please check the following approach: