DT
DT copied to clipboard
Can't access input$[...]_cell_edit if editing is disabled for some columns
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)
Same issue see this SO question.
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!
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 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
.