Hello,
I have been working on Shiny app. I like to insert hyperlink to DT datatable (FIRST column).
I have got the code and it is running fine for a small dataset. But I have a very large file (25000 rows). It takes 15-20 min.
So to save loading time, I like to insert hyperlinks to rows on current view in datatable. So instead of inserting hyperlink to whole dataset prior to loading, I just want hyperlink inserted as the datatable view changes.
Can anyone help me to achieve this?
Many thanks.
Here is my code:
library(shiny)
createLink <- function(val) {
sprintf('<a href="https://www.google.com/#q=%s" target="_blank" >%s</a>',val,val)
}
ui <- fluidPage(
titlePanel("Table with Links!"),
sidebarLayout(
sidebarPanel(
h4("Click the link in the table to see
a google search for the car.")
),
mainPanel(
dataTableOutput('table1')
)
)
)
server <- function(input, output) {
output$table1 <- renderDataTable({
dt <- datatable(mtcars, escape=FALSE, selection = 'none') %>% formatStyle(0, cursor = 'pointer')
})
observe({
List <- input$table1_rows_current
List <- createLink(List)
return(List)
})
}
shinyApp(ui, server)