Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can use the input$tableId_rows_selected variable to obtain the rows that have been selected in the Shiny DT. "tableId" should be replaced with the ID of the DT.

Here is an example code snippet for obtaining the selected rows:

output$selectedRows <- renderText({
  selected <- input$tableId_rows_selected
  if (length(selected) == 0) {
    "No rows selected."
  } else {
    paste("Selected row(s): ", paste(selected, collapse = ", "))
  }
})

This code will display the index(es) of the selected row(s) if any rows are selected, otherwise it will display "No rows selected."