In the below application, I am using cell_edit to display the row, col and value I have edited. But there is some issue here. Whenever I enter values in rows, (The result shows 1,1,1,1,1,1,..... instead of just 1), Also if I enter values in Col 1 and Col 2, (the result shows 0, 1,2,3,4,.... instead of only 1 and 2), Also if I enter values as 12 in row1 and col1 and 6 in row1 and Col2, the result shows as "12" "6" "160" ..... and so on, instead of only "12" "5" .
So basically it the result shows all values. Can we make it so that the result shows accordingly.
library(shiny)
ui <- fluidPage(
h2("Last edited:"),
verbatimTextOutput("last_edited"),
actionButton("reset", "Reset cell edited"),
h2("Datatable:"),
DT::dataTableOutput("dt")
)
server <- function(input, output) {
# the last selected/clicked value
output$last_edited <- renderPrint({
str(input$dt_cell_edit)
})
output$dt <- DT::renderDataTable({
DT::datatable(head(mtcars, 2), editable = 'row', rownames = F, selection = "none")
})
# observe the selected rows and do something after a new selection
observeEvent(input$dt_cell_edit, {
# validate(need(!is.null(input$dt_cell_edit), ''))
print(input$dt_cell_edit$row)
print(input$dt_cell_edit$col)
print(input$dt_cell_edit$value)
})
myProxy = DT::dataTableProxy('dt')
# reset last selected value
observeEvent(input$reset, {
DT::selectCells(myProxy, selected = NULL)
})
}
shinyApp(ui, server)