Using DataTables row selection inside shiny module

111 views
Skip to first unread message

Carl Ganz

unread,
Jun 15, 2016, 4:45:35 PM6/15/16
to Shiny - Web Framework for R
Hi everyone,

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

I feel like I am missing something about how modules work, so any guidance would be appreciated.

Kind Regards
Reply all
Reply to author
Forward
0 new messages