rstudio / shinydashboard

Shiny Dashboarding framework
https://rstudio.github.io/shinydashboard/
Other
893 stars 298 forks source link

DataTable width #292

Closed SemiQuant closed 6 years ago

SemiQuant commented 6 years ago

Hi, it seems that to render data tables in the dashboardBody don't automatically resize and overflow the page without allowing for scrolling. I've tried options all the options I could think of or find online. Example below (if you zoom out on your browser you'll see its printing the whole table)

require(shiny)
require(shinydashboard)
require(DT)

shinyApp(
  ui = dashboardPage(
    dashboardHeader(),
    dashboardSidebar(),
    dashboardBody(DT::dataTableOutput('dt'),
                  # This one renders and resizes correctly
                  DT::dataTableOutput('dtsmall'),
                  DTOutput('dt2'))
  ),

  server = function(input, output, session) {
    output$dt <- DT::renderDataTable(cbind(cbind(head(mtcars), head(mtcars)),cbind(head(mtcars), head(mtcars))))
    output$dt2 <- DT::renderDT(cbind(cbind(head(mtcars), head(mtcars)),cbind(head(mtcars), head(mtcars))))
    output$dtsmall <- DT::renderDataTable(head(mtcars))
  }
)
wch commented 6 years ago

I think you need to put it in a box().

SemiQuant commented 6 years ago

thanks, tried that but it plots over it, only the buttons and search bar respect it.

wch commented 6 years ago

You might also need to use scrollX=TRUE for renderDataTable. https://stackoverflow.com/a/32150285/412655