We are trying to recreate example: https://demo.shinyapps.io/029-row-selection/ , using the DT package for rendering the data frame instead of the shiny package. DT::Datatable also has the 'callback' option but it doesn't seem to work when using the same javascriptcode as in the demo.
our current code:
shinyServer(function(input, output) {
output$tbl <- DT::renderDataTable(
DT::datatable(mtcars,options = list(pageLength = 10,
callback = JS("function(table) {
table.on('click.dt', 'tr', function() {
$(this).toggleClass('selected');
Shiny.onInputChange('rows',
table.rows('.selected').indexes ().toArray());
});
}")
))
)
output$rows_out <- renderText({
paste(c('You selected these rows on the page:', rows),
collapse = ' ')
})
})
Does anyone knows how to achieve this?
Many thanks in advance, Thomas
PS: In the following example we found how to color columns in a datatable: renderDataTable Select all cells containing value > 10 and highlight