diff --git a/global.R b/global.R index 1205636..c36a0b2 100644 --- a/global.R +++ b/global.R @@ -29,6 +29,13 @@ library(DTedit) library(psrc.travelsurvey) library(shinyjs) + +df <- data.frame( + Buy = c('Tea', 'Biscuits', 'Apples'), + Quantity = c(7, 2, 5), + stringsAsFactors = FALSE +) + # Run Modules Files --------------------------------------------------------------------------- # This section runs the modules and unless the folder name changes, it doesn't need to be changed # It also loads in useful functions for dashboard creation diff --git a/modules/transit-region.R b/modules/transit-region.R index 5d8da4b..9d4a367 100644 --- a/modules/transit-region.R +++ b/modules/transit-region.R @@ -1,30 +1,23 @@ transit_region_ui <- function(id) { ns <- NS(id) - tagList( - uiOutput(ns("transitregion")) - ) + uiOutput(ns(id)) + } -transit_region_server <- function(id) { +transit_region_server <- function(id, mydata) { + moduleServer(id, function(input, output, session){ ns <- session$ns - output$edit_table <- dtedit(input, output, - # name = id, - name = "edit_table", - thedata = data.frame( - Buy = c('Tea', 'Biscuits', 'Apples'), - Quantity = c(7, 2, 5), - stringsAsFactors = FALSE - )) - - output$transitregion <- renderUI({ - tagList( - fluidRow(column(12,uiOutput(ns("edit_table")))), - hr(style = "border-top: 1px solid #000000;") - ) - }) + return( + dtedit(input = input, + output = output, + name = id, + id = id, + thedata = mydata) + ) + }) # end moduleServer } \ No newline at end of file diff --git a/server.R b/server.R index 8e3ebb3..27c1b3d 100644 --- a/server.R +++ b/server.R @@ -11,7 +11,14 @@ shinyServer(function(input, output) { transit_overview_server('OVERVIEWtransit') # Regional NTD metrics - transit_region_server('REGIONtransit') + ## Option A: the module below is how to place dtedit inside a module ---- + transit_region_server('REGIONtransit', mydata = df) + + ## Option B: "dtedit_server" is already a module, straight from the DTedit package. "df" is defined in global.R ---- + dtedit_server(id = 'dtedit_example', + thedata = df, + edit.cols = names(df), + edit.label.cols = names(df)) # Regional NTD metrics by Mode transit_mode_server('MODEtransit') diff --git a/ui.R b/ui.R index 53acb06..6c9940d 100644 --- a/ui.R +++ b/ui.R @@ -25,7 +25,13 @@ shinyUI( fluidRow(column(12, style='padding-left:25px; padding-right:50px;', tabsetPanel(type = "pills", tabPanel("Overview", transit_overview_ui('OVERVIEWtransit')), - tabPanel("Mode Error", transit_region_ui('REGIONtransit')), + + ## Option B: "dtedit_ui" is already a module, straight from DTedit package ---- + tabPanel("Mode Error", dtedit_ui('dtedit_example')), + + ## Option A: the module below is how to place dtedit inside a module ---- + tabPanel("Mode Error 2", transit_region_ui('REGIONtransit')), + tabPanel("PUDO, no +/- traveler", transit_mode_ui('MODEtransit'))) )),