Get selected row value instead of number in shiny using DT

Viewed 5614

Small question here: I know I can access selected rows by input$dfname_rows_selected it gives back the numbers of rows selected, but how do I read the rows names, not numbers? In my case they are generated not in the order I use them later, therefore I need to get the values inside to make it work.

edit: added example

ui <- shinyUI(fluidPage(

  DT::dataTableOutput("table"),
  actionButton("btn", "press me")

))

server <- function(input, output) {
  observeEvent(input$btn, {
    print(input$table_rows_selected)
  })

  output$table <- DT::renderDataTable({

    mtcars %>%
      datatable(selection = "multiple")

  })

}
shinyApp(ui = ui, server = server)
2 Answers
Related