I am having trouble getting DataTable's row selection to work in a module. I want the module to input a dataframe, and output the rows selected, but I get errors about being outside of the active reactive context. Here is a small example:
# module ui
testUI <- function(id) {
ns <- NS(id)
DT::dataTableOutput(ns("testTable"))
}
# module server
test <- function(input,output,session,data) {
output$testTable <- DT::renderDataTable({
data
}, selection=list(mode="multiple",target="row"))
### PROBLEM SEEMS TO BE HERE
return(input$testTable_rows_selected)
}
# app
shinyApp(
ui = fluidPage(
testUI("one"),
verbatimTextOutput("two")
),
server = function(input,output) {
out <- callModule(test,"one",mtcars)
output$two <- renderPrint(out) # using out() generates same error
}
)