user3577904
user3577904

Reputation: 491

Shinydashboard - DataTable width

I want to create shinydashboard with plots&tables but when using tabPanels, dataTable is always outside the box. I tried to specify panel width with column and width parameter, but it only affects the plot.

Is there a way to restrict datatable so that it is displayed only within the tabPanel? Thanks

enter image description here

Tab is rendered using this code:

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"))
            )

          )
          )
  )

Upvotes: 0

Views: 1022

Answers (1)

Barbara
Barbara

Reputation: 1168

I think that you would actually need to fix the server part and allow to scroll the columns. You should try something like this:

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

Not sure that it will work because I was not able to reproduce your problem. Try and let me know.

Upvotes: 2

Related Questions