I am interested to have a data table as following in my shiny
app. After I select the rows using the check boxes, I would like to continue working on the selected data. The problem now is that I don't know how to get the index of the selected rows from this example. Can you please help?
I want to extend the following code which is given by this answer.
library(shiny)
library(DT)
runApp(list(
ui = fluidPage(dataTableOutput("dtout")),
server = function(input, output, session) {
shinyInput <- function(FUN, id, num, ...) {
inputs <- character(num)
for (i in seq_len(num)) {
inputs[i] <- as.character(FUN(paste0(id, i), label = NULL, ...))
}
inputs
}
output$dtout <- renderDataTable({
datatable(
cbind(
Pick = shinyInput(
checkboxInput,
"srows_",
nrow(mtcars),
value = NULL,
width = 1
),
mtcars
),
options = list(
drawCallback = JS(
'function(settings) {Shiny.bindAll(this.api().table().node());}'
)
),
selection = 'none',
escape = F
)
}, server = FALSE)
}
))
I think it has to do with the callback
function. But I couldn't figure it out.