719016
719016

Reputation: 10431

Rstudio shiny select row in DataTables?

Is there anyway to have select row working with dataTables in Shiny?

http://datatables.net/examples/api/select_row.html

This post in shiny-discuss seems to indicate that it is not possible, but it's quite an old post:

https://groups.google.com/forum/#!topic/shiny-discuss/_zNZMR2gHn0

Anyone have a working example in gist or elsewhere?

Upvotes: 5

Views: 1182

Answers (2)

Shiva
Shiva

Reputation: 799

Try this:

.row() function makes it possible to get the data when a particular row is clicked.

shinyServer(function(input, output) {
       output$table_data <- DT::renderDataTable({
                                datatable(df,
                                          escape = FALSE,
                                          callback = JS(
                                          'table.on("click.dt","tr",function() {
                                               var data1 =table.row(this).data();
                                               console.log(data1);
                                         })'
                                       ))
                                  })
})

Upvotes: 1

Anderson Silva
Anderson Silva

Reputation: 729

Maybe the version you are using its a little old. Look at this: http://datatables.net/reference/api/row()

Upvotes: 2

Related Questions