【问题标题】:Adding a vertical and horizontal scroll bar to the DT table in R shiny在 R 闪亮的 DT 表中添加垂直和水平滚动条
【发布时间】:2018-05-10 09:27:42
【问题描述】:

请查看右侧数据表“案例分析详情”。我想将数据表放入框内,使其从框的右侧和底部边框对齐,以便我们向 DT 添加一个水平和垂直滚动条,该滚动条可用于跨越超出框的行。

## app.R ##
library(shiny)
library(shinydashboard)
library(DT)
ui <- dashboardPage(
dashboardHeader(title = "My Chart"),
dashboardSidebar(
width = 0
),
dashboardBody(
box(title = "Data Path", status = "primary",height = "595" ,solidHeader = T,
    plotOutput("trace_plot")),
box( title = "Case Analyses Details", status = "primary", height = 
"595",width = "6",solidHeader = T, 
     div(DT::dataTableOutput("trace_table",width = 220)))
))
server <- function(input, output) 
{ 
#Plot for Trace Explorer
output$trace_plot <- renderPlot({
plot(iris$Sepal.Length,iris$Sepal.Width)
})
output$trace_table <- renderDataTable({
mtcars
})
}
shinyApp(ui, server)

【问题讨论】:

    标签: r shiny dt shinyapps


    【解决方案1】:

    这样的事情吗?

    rm(list = ls())
    ## app.R ##
    library(shiny)
    library(shinydashboard)
    library(DT)
    ui <- dashboardPage(
      dashboardHeader(title = "My Chart"),
      dashboardSidebar(
        width = 0
      ),
      dashboardBody(
        box(title = "Data Path", status = "primary",height = "595" ,solidHeader = T,
            plotOutput("trace_plot")),
        box( title = "Case Analyses Details", status = "primary", height = 
               "595",width = "6",solidHeader = T, 
             column(width = 12,
                    DT::dataTableOutput("trace_table"),style = "height:500px; overflow-y: scroll;overflow-x: scroll;"
             )
        )))
    server <- function(input, output) { 
      #Plot for Trace Explorer
      output$trace_plot <- renderPlot({
        plot(iris$Sepal.Length,iris$Sepal.Width)
      })
      output$trace_table <- renderDataTable({
    
        datatable(cbind(mtcars,mtcars), options = list(paging = FALSE))
    
      })
    }
    shinyApp(ui, server)
    

    【讨论】:

    • 嗨@Pork Chop...对于水平滚动,可以添加:div(style = 'overflow-x: scroll',DT::dataTableOutput("trace_table",width = "100%"))
    • @Subhasish1315,也感谢您的建议。
    • @PorkChop,我这里有一个问题,当我水平滑动桌子时,我看不到最后三列滑动。请帮忙。
    • 调查一下
    • @AshminKaul 见上文
    猜你喜欢
    • 2019-04-13
    • 2017-06-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-07
    • 2017-11-24
    • 1970-01-01
    相关资源
    最近更新 更多