简体   繁体   中英

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?

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

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);
                                         })'
                                       ))
                                  })
})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM