-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
When using output elements inside a dq_accordion
only the output's in the first accordion are shown unless you force load all the outputs inside the accordion, or put output inside an module. However this trick does not work for DataTables
library(shiny)
mod_2_ui <- function(id){
ns <- NS(id)
tagList(
uiOutput(ns("outUI"))
)
}
mod_2_server <- function(input, output, session){
ns <- session$ns
vals <- reactiveValues(selected = NULL)
output$outUI <- renderUI({
tagList(
selectizeInput(inputId = ns("selected"), label = "Select a slide", multiple = FALSE, choices = c(1:5), selected = 3)
)
})
outputOptions(output, "outUI", suspendWhenHidden = FALSE)
observeEvent(input$selected, {
vals$selected = input$selected
})
return(vals)
}
content = list()
content[["first"]] <- tagList(
textOutput("testOut_1"),
DT::dataTableOutput("table_1")
)
content[["second"]] <- tagList(
textOutput("testOut_2")
)
content[["third"]] <- tagList(
mod_2_ui(id = "selected_3")
)
content[["fourth"]] <- tagList(
DT::dataTableOutput("table_2")
)
ui <- fluidPage(
fluidRow(
column(12, offset = 0,
div(style="height:0px; top:20px"),
dqshiny::dq_space("30px"),
shiny::div(
class = "",
style = "max-height: 80vh;height:auto",
dqshiny::dq_accordion(
id = "outer",
titles = names(content),
content = content,
bg_color = "#f7f9fc",
options = list(animate = 500, collapsible = TRUE, heightStyle = "content"),
sortable = FALSE,
hover = TRUE,
icons = c(rotate = "angle-right")
)
)
)
)
)
server <- function(input, output) {
selected_3 <- callModule(mod_2_server, "selected_3")
output$testOut_1 <- renderText({"First output"})
output$testOut_2 <- renderText({"Second output"})
output$table_1 <- DT::renderDataTable({DT::datatable(datasets::iris)})
output$table_2 <- DT::renderDataTable({DT::datatable(datasets::iris)})
# Only works if you uncomment the line below
# outputOptions(output, "testOut_2", suspendWhenHidden = FALSE)
outputOptions(output, "table_2", suspendWhenHidden = FALSE)
}
shinyApp(ui = ui, server = server)
Session Info
> sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.5 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_IE.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_IE.UTF-8 LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_IE.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_IE.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils methods base
other attached packages:
[1] dqshiny_0.0.5 shiny_1.6.0 colorout_1.2-2
loaded via a namespace (and not attached):
[1] Rcpp_1.0.5 digest_0.6.27 later_1.1.0.1 mime_0.7 R6_2.4.0 lifecycle_1.0.0
[7] xtable_1.8-4 magrittr_2.0.1 evaluate_0.14 rlang_0.4.10 promises_1.1.1 ellipsis_0.3.1
[13] rmarkdown_1.15 tools_3.6.3 yaml_2.2.1 xfun_0.9 httpuv_1.5.4 fastmap_1.0.1
[19] compiler_3.6.3 htmltools_0.5.1.1 knitr_1.24
Metadata
Metadata
Assignees
Labels
No labels