glin / reactable

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

Question : If resizable = TRUE and colDef(width) are used, resizable disabled. #223

Open daeyoonlee opened 2 years ago

daeyoonlee commented 2 years ago

Thanks for the great package.

Currently setting width in colDef seems to disable resizable. minwidth and maxwidth are also forced. Is this intentional? I want to width only as an initial value and allow resizable. but there seems to be no way. If only min width and maxwidth are used, resizable is possible, but the initial value is minwidth.

library(shiny)
library(reactable)

ui <- fluidPage(
  reactableOutput(outputId = "table"),
)

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

  output$table <- renderReactable(
    reactable(
      data = iris,
      bordered = TRUE,
      resizable = TRUE,
      columns = list(
        Species = colDef(minWidth = 150, width = 200, maxWidth = 250)
      )
    )
  )

}

shinyApp(ui, server)

image

glin commented 2 years ago

Yes, this was intentional, or at least semi-intentional when resizing was reworked to respect the min and max widths of columns. Disabling resizing on fixed-width columns wasn't a primary intention, but came along with that rework. I can see how resizing would be useful on fixed-width columns though.

Unfortunately, resizing can't be easily reenabled on fixed-width columns without undoing the work to limit resizing to min/max widths. It's somewhat complicated, so I'll tag this as a feature request to look into later for now.

daeyoonlee commented 2 years ago

thank you for the reply. If modifying the width option is complicated, it may be an alternative to add initWidth to the option. That is, if width is provided, initWidth is ignored(fixed width), if width is not provided and initWidth is provided, then initWidth is initialized. (in this case resizable should be possible)