How to make the horizontal scrollbar visible in DT::datatable

前端 未结 3 933
庸人自扰
庸人自扰 2021-01-01 10:51

Using R shiny & DT package, I am creating certain tables. The number of columns vary as per user input & is not fixed. I have included the following code snippet to

3条回答
  •  时光说笑
    2021-01-01 11:17

    I don't think you can (or should) force a scrollbar easily if you don't need one, but the above code works fine for me, it shows a scrollbar when the page initializes. Maybe the problem is with the data or something else.

    Here's a minimal example that has a horizontal scrollbar on page load

    runApp(shinyApp(
      ui = fluidPage(
        DT::dataTableOutput("results", width = 300)
      ),
      server = function(input, output, session) {
        output$results <- DT::renderDataTable(
          mtcars,
          options = list(scrollX = TRUE)
        )
      }
    ))
    

提交回复
热议问题