Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collapsing of boxes not working with dynamic output #17

Closed
rpinsler opened this issue Mar 6, 2015 · 4 comments
Closed

Collapsing of boxes not working with dynamic output #17

rpinsler opened this issue Mar 6, 2015 · 4 comments

Comments

@rpinsler
Copy link

rpinsler commented Mar 6, 2015

When I generate a box with collapsible=TRUE on the server side, the collapse button doesn't work anymore - even if the box has no content at all:

library(shiny)
body <- dashboardBody(
  uiOutput("ui")
)

server <- function(input, output) {  
  output$ui <- renderUI({
    box(title = "Collapse me",
        status = "warning", solidHeader = TRUE, collapsible = TRUE
    )
  })
}

shinyApp(
  ui = dashboardPage(
    dashboardHeader(),
    dashboardSidebar(),
    body
  ), 
  server = server
)

Would be great if you can get this to work as it is a quite common use case.

Best regards,
Robert

@phillc73
Copy link

I had a look at your code and think I've found a fix. Basically, move the box() into dashboardBody(), and just have the content of the box in output$ui.

Here's some code, with an extra box() added just for fun:

library("shinydashboard")

body <- dashboardBody(
    box(title = "Collapse Me",
        width = 6,
        status = "warning", 
        solidHeader = TRUE, 
        collapsible = TRUE,
        uiOutput("ui")
        ),
    box(title = "Collapse Me Too!", 
        width = 6,
        status = "success", 
        solidHeader = TRUE, 
        collapsible = TRUE,
        uiOutput("uiToo")
        )
  )

server <- function(input, output) {

  output$ui <- renderUI({
    paste("Click to see the box collapse")
    })

  output$uiToo <- renderUI({
    paste("Click to see another box collapse")
    })
}

shinyApp(
  ui = dashboardPage(
    dashboardHeader(),
    dashboardSidebar(),
    body
  ),
  server = server
)

I hope that helps.

As an aside, if you use the "height" attribute within the box(), just the content within the box collapses and not the box() itself, which is somewhat interesting.

@wch
Copy link
Contributor

wch commented Mar 27, 2015

I think the root of the problem is that the Javascript code expects that the various components only need to be initialized when the page is loaded. I'll see what can be done.

@wch wch closed this as completed in 692dc96 Mar 27, 2015
@wch
Copy link
Contributor

wch commented Mar 27, 2015

I've pushed a fix. I'll also try to get it in the upstream AdminLTE sources.

@happyshows
Copy link

@wch
Hi Wiston, is there a way to call the show/hide events from a button?
I am using loops to dynamically generate a couple boxes. I want the user to be able to click a button to expand all / collapse all at their preference. Is there some syntax like updateBox(collapse=FALSE/TRUE)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants