仪表板主体不会随着DT长度的变化而调整大小

时间:2018-04-09 16:17:25

标签: r shiny shinydashboard dt

当DTOutput显示更多行时,仪表板页面不会展开。输出是可见的,但看起来它不再包含在仪表板页面中。

ui <- function() { 
 dashboardPage(
  dashboardHeader(),
  dashboardSidebar(),
  dashboardBody(
   mainPanel(width = 12,
             fluidRow(DTOutput(outputId = "table"))
  )))}

server <- function(input, output) {
 data <- data.frame(1:100)
 output$table <- renderDT(
  data
 )
}

shinyApp(ui = ui, server = server)

Screenshot of issue.

仪表板页面的灰色背景在第15行附近结束。

1 个答案:

答案 0 :(得分:0)

这可以通过在文档中添加一些CSS来解决:

section.content { 
  overflow-y: hidden; 
}

<强> MWE:

library(shiny)
library(shinydashboard)
library(DT)
library(htmltools)
ui <- function() { 
  dashboardPage(
    dashboardHeader(),
    dashboardSidebar(),
    dashboardBody(
      tags$head(tags$style("section.content { overflow-y: hidden; }")),
      mainPanel(width = 12,
                fluidRow(DTOutput(outputId = "table"))
      )))}

server <- function(input, output) {
  data <- data.frame(1:100)
  output$table <- renderDT(
    data
  )
}

shinyApp(ui = ui, server = server)