0

Is there a simple way to get the following tabBox to span the entire height of the dashboardBody?

app_ui <- function() {

    shinydashboard::dashboardPage(
      shinydashboard::dashboardHeader(title = "Baseball Statistics"),
      
      shinydashboard::dashboardSidebar(
        width = 250
      ),
      
      shinydashboard::dashboardBody(
        shinydashboard::box(title = "Individual"),
        shinydashboard::tabBox(title = "Stats",
                               shiny::tabPanel("Batting", DT::DTOutput("batting")),
                               shiny::tabPanel("Pitching", DT::DTOutput("pitching")),
                               shiny::tabPanel("Fielding", DT::DTOutput("fielding"))
                               )
      )
    )
}

I would like the datatable to occupy as much vertical screen as possible:

screenshot

The following answer was not successful - Shinydashboard Tabbox Height

I attempted to integrate the above answer by:

      shinydashboard::dashboardBody(
        shinydashboard::box(title = "Individual"),
        shinydashboard::tabBox(title = "Stats",
                               shiny::tags$head(
                                 shiny::tags$style(shiny::HTML(" #tabBox { height:90vh !important; } "))
                               ),
                               id="tabBox",
                               shiny::tabPanel("Batting", DT::DTOutput("batting")),
                               shiny::tabPanel("Pitching", DT::DTOutput("pitching")),
                               shiny::tabPanel("Fielding", DT::DTOutput("fielding"))
                               )
      )

The output looks like:

screenshot2

Dylan Russell
  • 936
  • 1
  • 10
  • 29

2 Answers2

0

It probably depends on the oter DT options.

When I use only scrollX options

  output$batting <- renderDT(iris, 
                             options = list( scrollX = TRUE))

I get enter image description here

HubertL
  • 19,246
  • 3
  • 32
  • 51
  • So how can you add in scrollbars to the DT so you can scroll to parts of the data that are cut off? – Dylan Russell Mar 03 '21 at 20:16
  • eg.: output$dataset <- DT::renderDT(dataframes$df.response, options = list( scrollX = TRUE, lengthMenu = c(15, 50, 100, 200, 500), colReorder = list(realtime = FALSE) ) ) with scrollX – Patrick Bormann Mar 03 '21 at 20:18
  • Perfect, that adds a horizontal scrollbar. Now it's only running way off the bottom of the page, especially when I select show 100 rows. Is there a way to limit the vertical extension? – Dylan Russell Mar 03 '21 at 20:28
  • I edited to add scrolling and paging. With paging it can not span further than pagelength – HubertL Mar 03 '21 at 20:32
0

This is my final try, it seems the other things didn't work out, so:

  output$dataset <- DT::renderDT(dataframes$df.response,
    callback = JS(js),
    filter = "top",
    rownames = FALSE,
    selection = list(target = "row+column"),
    extensions = c("ColReorder"),
    options = list(
      # scrollX = TRUE,
      # lengthMenu = c(15, 50, 100, 200, 500),
      # colReorder = list(realtime = FALSE),
      pageLength = 1000,
      scrollY=TRUE
   )
  )

the pagelength element to the max rows of your data set it will show it entirely when loading. like in this screen:lasttry. Is this a possible workaround for you?

Patrick Bormann
  • 729
  • 6
  • 16