Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 376
719016 Avatar asked Oct 20 '22 05:10

719016


2 Answers

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

like image 187
Anderson Silva Avatar answered Oct 22 '22 19:10

Anderson Silva


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);
                                         })'
                                       ))
                                  })
})
like image 43
Shiva Avatar answered Oct 22 '22 18:10

Shiva