glin / reactable

Interactive data tables for R
https://glin.github.io/reactable
Other
613 stars 79 forks source link

Using pagination = FALSE seems to automatically set the pagesize to max row of df #214

Closed daeyoonlee closed 2 years ago

daeyoonlee commented 2 years ago

Thanks for the great package.

Using pagination = FALSE seems to automatically set the pagesize to max row of df. Because of this, overflowing rows may appear to not be rendered. (Increasing max-row does nothing)

library(shiny)
library(reactable)

ui <- fluidPage(
  numericInput(inputId = "max_rows", label = "max_rows", value = 12),
  reactableOutput(outputId = "table"),
)

server <- function(input, output, session) {

  output$table <- renderReactable(
    reactable(
      data = iris[1:isolate(input$max_rows),],
      pagination = FALSE,
      showPagination = FALSE,
      selection = "single",
      selectionId = "table_rows_selected",
      onClick = "select"
    )
  )

  observe(
    updateReactable(
      outputId = "table",
      data = iris[1:input$max_rows,]
    )
  )
}

shinyApp(ui, server)

Currently to solve this, pagination = TRUE and defaultPageSize to a large enough number.

library(shiny)
library(reactable)

ui <- fluidPage(
  numericInput(inputId = "max_rows", label = "max_rows", value = 12),
  reactableOutput(outputId = "table"),
)

server <- function(input, output, session) {

  output$table <- renderReactable(
    reactable(
      data = iris[1:isolate(input$max_rows),],
      pagination = TRUE,
      defaultPageSize = 10000,
      showPagination = FALSE,
      selection = "single",
      selectionId = "table_rows_selected",
      onClick = "select"
    )
  )

  observe(
    updateReactable(
      outputId = "table",
      data = iris[1:input$max_rows,]
    )
  )
}

shinyApp(ui, server)
glin commented 2 years ago

Good catch, this was an easy way to "disable" pagination, but I guess it breaks down when you use updateReactable() to change the data 😅. This should now be fixed in the dev version (https://github.com/glin/reactable/commit/f406c62624eccaef277a66c361862f4c4a04a671), so pagination = FALSE should work in all cases. Thanks!

daeyoonlee commented 2 years ago

Thank you!