Editable DT table with content coming from uploaded file

Hi,

I am trying to build an app which includes an editable DT table with a default content. I would like to allow users to upload a file (using fileInput()) to overwrite the default content of the DT table. The content of the DT table should be replaced every time a user upload a new file.
Based upon the documentation of DT and a few posts published here and stackoverflow, it seems that the default server-side vehicle for storing the data showed in the DT table is a static data.frame (akin to iris) or reactiveValues object... which does not accept a reactive as an input. So I am a bit stuck with the reactive object created from my data upload...
Birdman recently posted a question that indicates that it should be possible to use data coming from an uploaded file into DT, instead of a fixed data.frame as described in the example (https://yihui.shinyapps.io/DT-edit/). However, there was no code attached to his/her post...

Any help would be welcome

Thanks



library(shiny)
library(DT)
ui <- fluidPage(
  DTOutput("myout"),
  selectInput('sel',"choose input frame",
              choices = c("mtcars","iris","PlantGrowth"))
)

server <- function(input, output, session) {
  
  datatablecontent <- reactiveVal()
  
  output$myout <- renderDT({
    req(datatablecontent())
  })
  
  observeEvent(input$sel,
               datatablecontent(get(input$sel)))
}

shinyApp(ui, server)

Thank you for your response.

Birdman also provided some additional insight on the original thread. Solution can be found there.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.