DT icon indicating copy to clipboard operation
DT copied to clipboard

Utilizing Scroller DataTable extension with `datatable(fillContainer = TRUE, ...)`

Open jthompson-arcus opened this issue 1 year ago • 1 comments

The DataTable Scroller extension does not work correctly when using datatable(fillContainer = TRUE, ...). I was able to figure out a work around for my issue utilizing the "scrollResize" plugin. Stackoverflow issue and workaround can be found here. Below is a toy example showing the issue. When the table loads, everything looks okay, but after you start scrolling the table gets reduced to only 9 rows. This is true regardless of the value given to the scrollY option. You will also notice that the pagination gets reduced to only one record (i.e. "Showing 44 to 44 of 150 entries").

library(shiny)
library(DT)

ui <- fluidPage(
  div(
    style = "height: 500px",
    DT::DTOutput("table", height = "100%")
  )
)

server <- function(input, output, session) {
  output$table <- DT::renderDT({
    DT::datatable(
      iris,
      options = list(
        scrollY = 200,
        scroller = TRUE,
        deferRender = TRUE
      ),
      fillContainer = TRUE,
      extensions = "Scroller",
    )
  })
}

shinyApp(ui, server)

By filing an issue to this repo, I promise that

  • [x] I have fully read the issue guide at https://yihui.org/issue/.
  • [x] I have provided the necessary information about my issue.
    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('DT'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: remotes::install_github('rstudio/DT').
    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.
  • [x] I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises.

jthompson-arcus avatar May 29 '24 20:05 jthompson-arcus

I wanted to add that I would have opened an identical issue, as I have encountered this as well.

alanfarahani avatar Oct 08 '24 18:10 alanfarahani