0

I am using DTEdit to allow users to edit a datatable in my Shiny app. It works well and displays the user's updates/inserts in the UI. However, I want to be able to perform functions on the updated table. Is there a way to return the updated table to the server side as well as the UI side?

wylie
  • 173
  • 11
  • 1
    Hi, it will be much easier to help you if you provide a [minimal, reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – bretauv May 21 '20 at 19:08

1 Answers1

1

dtedit's main method to handle user editing of data is by using and defining callbacks.

However, dtedit does return a reactiveValues. Server-side, changes in 'reactiveValues' can be detected in an observeEvent.

I have examples of using both the return list of reactiveValues and use of callbacks in a vignette, based on my modified version of DTedit. Previously my version of DTedit returns a list of 'reactives', rather than a 'reactiveValues', but now returns reactiveValues, just like jryer/DTedit.

Using jbryer/DTedit :

server <- function(input, output) {
    
    Grocery_List_Results <- dtedit(
        input, output,
        name = 'Grocery_List',
        thedata = data.frame(
            Buy = c('Tea', 'Biscuits', 'Apples'),
            Quantity = c(7, 2, 5),
            stringsAsFactors = FALSE
        )
    )
    
    observeEvent(Grocery_List_Results$thedata, {
        message(Grocery_List_Results$thedata)
    })
    
}

ui <- fluidPage(
    h3('Grocery List'),
    uiOutput('Grocery_List')
)

shinyApp(ui = ui, server = server)
David Fong
  • 506
  • 4
  • 3