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

醉酒当歌 提交于 2019-11-30 17:05:14

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)
    )
  }
))
Aditya Kothari

Try this:

DT::datatable(sta, options = list(
  pageLength=50, scrollX='400px'), filter = 'top')

I would have done this way also:

datasetInput1 <- reactive({
      infile <- input$file1
      if(is.null(infile))
        return(NULL) 
      else
        m <- read.csv(infile$datapath, header = input$header)
        return ( DT::datatable(m, extensions = 'Scroller', options = list(deferRender = F, dom = 't',
                                                                      columnDefs = list(list(className = 'dt-center',
                                                                                             targets = 5)),
                                                                     scrollY = 300, scroller = TRUE, scrollX = T,
                                                                     pageLength = 5))
               )
    })
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!