Function similar to cell_edit

Hi all,

Wanted to check if there is a function like row_edit similar to cell_edit in R.
For example

input$iris_cell_edit  ## takes values that is edited in each each

Actually I have 'row' instead of 'cell' so entire rows gets edited. So wanted to check if there is something called input$iris_row_edit. Please advice

For the benefit of others it should be said this question is related to your use of R library(DT).
Have you succeeded in creating a row edit solution in DT ? I'm having a hard time even visualising what this would mean, unless its a pop up form like in example "Full row editing" ?
the full documentation for the R implementation is
There is a lot of info about different approaches to DT editing here :

also you asked elsewhere about column-header editing. as an aside I found info for that here:

Hi Thanks,

Below is the reprex. Whatever we edit in 'cell' editing, it gets printed because we have used cell_edit. But in case if we edit entire row, can we get those values printed (like if we have rows_edit). Hope you got point :slight_smile:


dt_output = function(title, id) {
    12, h1(paste0('Table ', sub('.*?([0-9]+)$', '\\1', id), ': ', title)),
    hr(), DTOutput(id)
render_dt = function(data, editable = 'cell', server = TRUE, ...) {
  renderDT(data, selection = 'none', server = server, editable = editable, ...)

  ui = fluidPage(
    title = 'Double-click to edit table cells',
    dt_output('client-side processing (editable = "cell")', 'x1'),
    dt_output('client-side processing (editable = "row")', 'x2'),
    dt_output('client-side processing (editable = "column")', 'x3'),
    dt_output('client-side processing (editable = "all")', 'x4'),
    dt_output('server-side processing (editable = "cell")', 'x5'),
    dt_output('server-side processing (editable = "row")', 'x6'),
    dt_output('server-side processing (editable = "column")', 'x7'),
    dt_output('server-side processing (editable = "all")', 'x8'),
    dt_output('server-side processing (no row names)', 'x9'),
    dt_output('edit rows but disable certain columns (editable = list(target = "row", disable = list(columns = c(2, 4, 5))))', 'x10')
  server = function(input, output, session) {
    d1 = iris
    d1$Date = Sys.time() + seq_len(nrow(d1))
    d10 = d9 = d8 = d7 = d6 = d5 = d4 = d3 = d2 = d1
    options(DT.options = list(pageLength = 5))
    # client-side processing
    output$x1 = render_dt(d1, 'cell', FALSE)
    output$x2 = render_dt(d2, 'row', FALSE)
    output$x3 = render_dt(d3, 'column', FALSE)
    output$x4 = render_dt(d4, 'all', FALSE)
    # server-side processing
    output$x5 = render_dt(d5, 'cell')
    output$x6 = render_dt(d6, 'row')
    output$x7 = render_dt(d7, 'column')
    output$x8 = render_dt(d8, 'all')
    output$x9 = render_dt(d9, 'cell', rownames = FALSE)
    output$x10 = render_dt(d10, list(target = 'row', disable = list(columns = c(2, 4, 5))))
    # edit a single cell
    proxy5 = dataTableProxy('x5')
    observeEvent(input$x5_cell_edit, {
      info = input$x5_cell_edit
      str(info)  # check what info looks like (a data frame of 3 columns)
      d5 <<- editData(d5, info)
      replaceData(proxy5, d5, resetPaging = FALSE)  # important
      # the above steps can be merged into a single editData() call; see examples below
    # edit a row
    observeEvent(input$x6_cell_edit, {
      d6 <<- editData(d6, input$x6_cell_edit, 'x6')
    # edit a column
    observeEvent(input$x7_cell_edit, {
      d7 <<- editData(d7, input$x7_cell_edit, 'x7')
    # edit all cells
    observeEvent(input$x8_cell_edit, {
      d8 <<- editData(d8, input$x8_cell_edit, 'x8')
    # when the table doesn't contain row names
    observeEvent(input$x9_cell_edit, {
      d9 <<- editData(d9, input$x9_cell_edit, 'x9', rownames = FALSE)
    # edit rows but disable columns 2, 4, 5
    observeEvent(input$x10_cell_edit, {
      d10 <<- editData(d10, input$x10_cell_edit, 'x10')

i tested number 6 and it works fine only

  1. as user clicking on the table you must now to complete your submission of edited row by holding down control key and pressing enter key.
  2. the results weren't going into d6 globally for me when manually looking at my global environment when the shiny app was ended. therefore I made the following explicit change to example 6 so it would be there.
 # edit a row
    observeEvent(input$x6_cell_edit, {
             value = editData(d6, input$x6_cell_edit, 'x6'),
             envir = .GlobalEnv)
1 Like

Thanks a lot for this :slight_smile:

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.