Home > Back-end >  Add common vertical scroll for more than one dt::datatables
Add common vertical scroll for more than one dt::datatables

Time:07-25

Is it possible to add a common scroll Y for more than one datatables which are side to side?

## app.R ##
library(shiny)
library(shinydashboard)
library(DT)
ui <- dashboardPage(
  dashboardHeader(title = "My Chart"),
  dashboardSidebar(
    width = 0
  ),
  dashboardBody(
    
         column(width = 6,
                DT::dataTableOutput("trace_table"),style = "height:500px; overflow-y: scroll;overflow-x: scroll;",
         ),
         column(width = 6,
                DT::dataTableOutput("trace_table2"),style = "height:500px; overflow-y: scroll;overflow-x: scroll;",
         )
    ))
server <- function(input, output) { 
  #Plot for Trace Explorer
  
  output$trace_table <- renderDataTable({
    
    datatable(cbind(mtcars,mtcars), options = list(paging = FALSE))
    
  })
  output$trace_table2 <- renderDataTable({
    
    datatable(cbind(mtcars,mtcars), options = list(paging = FALSE))
    
  })
}
shinyApp(ui, server)

CodePudding user response:

ui <- dashboardPage(
  dashboardHeader(title = "My Chart"),
  dashboardSidebar(
    width = 0
  ),
  dashboardBody(
    column(
      width = 12,
      tags$div(
        style = "max-height:500px; overflow-y: scroll; overflow-x: scroll;",
        splitLayout(
          DTOutput("trace_table"),
          DTOutput("trace_table2")
        )
      )
    )
  )
)
  • Related