How to change R shiny Table input that I can fill the table without double clicking the cells.

Hello I use R shiny DT library to implement table input. I find that I need to double click the cells, then I can fill in the cells. I want to ask how can I change the code to make it input the data directly without double clicking.


I asked ChatGPT, it provide the code. But it does not work.

jscode <- "
function cell_editCallback(table) {
table.on('click.dt', 'td', function() {
var index = table.cell(this).index();
Shiny.setInputValue('table_cell_edit', {row: index[0], col: index[1]});

ui = fluidPage(
server = function(input, output, session) {
data <- iris

# Define callback for direct editing
session$onFlushed(function() {

output$table <- renderDT(
  callback = JS("cell_editCallback", "table"),
  selection = 'none',  # Prevent row selection
  server = FALSE  # Disable server-side processing

observeEvent(input$table_cell_edit, {
  row <- input$table_cell_edit$row
  col <- input$table_cell_edit$col
  data[row, col] <- isolate(input$table_cell_edit$value)


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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.