rstudio / DT

R Interface to the jQuery Plug-in DataTables
https://rstudio.github.io/DT/
Other
587 stars 184 forks source link

R Shiny application designed to navigate through multiple sections within a single page #1138

Open nivethajagadeeswarann opened 2 months ago

nivethajagadeeswarann commented 2 months ago

Below code works in IDE but not when i deploy to posit connect. Any idea ?

library(shiny) library(DT)

Sample data

data <- data.frame( ID = 1:20, Name = letters[1:20], Section = paste0("section", 1:20) )

Define UI

ui <- fluidPage( titlePanel("DataTable with Section Links"), mainPanel( DTOutput("mytable") ), fluidRow( column(12, tags$h2("Sections"), lapply(1:20, function(i) { tags$div(id = paste0("section", i), paste("Section", i, "content")) }) ) ) )

Define server logic

server <- function(input, output) { output$mytable <- renderDT({ datatable(data, options = list( columnDefs = list( list( targets = 3, render = JS( 'function(data, type, row, meta) {', 'return "<a href=\'#" + data + "\'>" + data + "";', '}' ) ) ) ) ) }) }

Run the application

shinyApp(ui = ui, server = server)