I am trying to capture edits to a datatable (mytable) and then create a second datatable (new_table) which reflects the edits. There is a separate input$rows and input$columns which determines how many rows/columns in the original mytable.
I can't seem to capture the output from the original mytable. Any help much appreciated
library(DT)
shinyApp(
ui = fluidPage(
textInput("rows",
"enter rows",
value = "2"),
textInput("columns",
"enter columns",
value = "3"),
DTOutput('mytable'),
DTOutput("new_table")
),
server = function(input, output) {
data <- reactive({
as.data.frame(matrix(" ",
as.numeric(input$rows),
as.numeric(input$columns)))
})
dfon <- reactiveValues(data = NULL)
output$mytable <- renderDataTable({
datatable(
data(),
editable = 'cell'
)
})
observeEvent(input$mytable_cell_edit, {
info = input$mytable_cell_edit
str(info)
#i = info$row
#j = info$col + 1 # offset by 1
#v = info$value
#dfon$top[i, j] <<- DT::coerceValue(v, dfon$top[i, j])
dfon$data <<- editData(dfon$data, info)
})
output$new_table <- renderDataTable({
datatable(dfon$data)
})
}
)