DT icon indicating copy to clipboard operation
DT copied to clipboard

Can't access input$[...]_cell_edit if editing is disabled for some columns

Open ismirsehregal opened this issue 2 years ago • 4 comments

Please see the example below.

When switching from editable = TRUE to editable = list(target = "column", disable = list(columns = 1:3))

input$myDT_cell_edit is no longer populated after editing a cell.

library(shiny)
library(DT)
library(datasets)

ui <- fluidPage(DT::dataTableOutput("myDT"))

server <- function(input, output, session) {
  output$myDT <- DT::renderDataTable({
    DT::datatable(
      mtcars,
      # editable = TRUE
      editable = list(target = "column", disable = list(columns = 1:3))
    )
  })
  
  observeEvent(input$myDT_cell_edit, {
    print("myDT_cell_edit")
  })
  
  observe({
    cat(paste(paste(names(session$input), collapse = ", "), "\n\n"))
  })

}

shinyApp(ui, server)

ismirsehregal avatar Aug 23 '21 11:08 ismirsehregal

Same issue see this SO question.

brucemoran avatar May 16 '22 13:05 brucemoran

I am having the same issue - it seems to affect editing of columns or rows, independent of whether you disable any cols/rows. Essentially I think the bug is that you can edit a column or row, but never "complete" the editing by clicking off the cells (like you do when editing a cell). input$myDT_cell_edit is therefore never set, as the datatable edit is never completed. So the only way to actually edit a datatable at present is to edit by cell. It would be very useful to have this fixed to make editing a row or column much more user friendly!

stevenjwest avatar Jul 28 '22 16:07 stevenjwest

It seems that clicking off the cells doesn't complete the edit, but Ctrl + Enter does. I learned this from the mouseover text when editing a row in Table 2 at this page of examples: https://yihui.shinyapps.io/DT-edit/

kaplanas avatar Feb 17 '23 04:02 kaplanas

@kaplanas thanks Ctrl+Enter works.

However, still the behaviour is inconsistent if one keeps in mind that Ctrl+Enter is not needed when using editable = TRUE.

ismirsehregal avatar Feb 17 '23 13:02 ismirsehregal