Shinydashboard - 数据表宽度

Shinydashboard - DataTable width

我想用绘图和表格创建 shinydashboard,但是当使用 tabPanels 时,dataTable 总是在框外。我尝试使用 column 和 width 参数指定面板宽度,但它只影响绘图。

有没有办法限制datatable只在tabPanel内显示? 谢谢

使用此代码呈现选项卡:

dashboardBody(
tabItems(
  # First tab content
  tabItem(tabName = "dashboard_total_results",
          fluidRow(

            column(width = 15,

            tabBox(
              title = "Total deal results",
              id = "deal_res_tabset_1", height = "250px",
              tabPanel("Total revenue", 
                       plotlyOutput("total_revenue_plot"),
                       DT::dataTableOutput("total_revenue_table")),
              tabPanel("Total orders", 
                       plotlyOutput("total_orders_plot"),
                       DT::dataTableOutput("total_orders_table")),
              tabPanel("Total margin", 
                       plotlyOutput("total_margin_plot"),
                       DT::dataTableOutput("total_margin_table"))
            )

          )
          )
  )

我认为您实际上需要修复 server 部分并允许滚动列。你应该尝试这样的事情:

output$yourtablename= DT::renderDataTable(server = TRUE,{
  DT::datatable(df,
                extensions=c("Buttons",'Scroller'),
                options = list(dom = 'Bfrtip',
                               scrollY = 500,
                               scroller = TRUE,
                               scrollX=TRUE
                )
  )
})

不确定它是否有效,因为我无法重现您的问题。试试让我知道。