rstudio/DT

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

nivethajagadeeswarann opened this issue · 0 comments

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)