ThomasSiegmund / D3TableFilter

A table widget based on Max Guglielmi's "HTML Table Filter Generator" and D3.js
Other
65 stars 17 forks source link

Setting Column Width / Resizing Issue #24

Open afpapa2 opened 7 years ago

afpapa2 commented 7 years ago

Test.zip This is a reproducible (at least on my end) example of what I was referring to in a previously closed issue. Two things are going on here on my data set (and not on the mtcars dataset) that are unusual, so I've attached the RDS file needed to be used in the following example code:

library(shiny)
library(htmlwidgets)
library(D3TableFilter)
data(Test)

# ui.R
# --------------------------------------------------------
ui <- fluidPage(
  titlePanel('Test app'),
  sidebarLayout(
    sidebarPanel(
      wellPanel(HTML(paste("D3TableFilter test app<br>Package version",
                           sessionInfo()$otherPkgs$D3TableFilter$Version)))
    ),
    mainPanel(
      br(),
      d3tfOutput('Test')
    )
  ))

# server.R
# --------------------------------------------------------
server <- shinyServer(function(input, output, session) {

  output$Test <- renderD3tf({

    # Define table properties. See http://tablefilter.free.fr/doc.php
    # for a complete reference
    tableProps <- list(
      btn_reset = TRUE,
      # alphabetic sorting for the row names column, numeric for all other columns
      #col_types = c("string", rep("number", ncol(WIPData))),
      alternate_rows = TRUE,
      col_0= 'select',col_1= 'select',col_2= 'select',
      col_widths = c('100px', '100px', '100px', '100px', '100px','100px', '100px', '100px', '100px', '100px','100px', '100px', '100px', '100px',
                     '700px','100px', '400px', '100px', '100px', '100px', '100px')
    );

    extensions <-  list(
      list( name = "colsVisibility",
            #at_start =  c(1,2,3,4,5),
            text = 'Hide Columns: ',
            enable_tick_all =  TRUE
      ),
      list(name = "sort"),
      list( name = "filtersVisibility",
            visible_at_start =  TRUE)
    );

    #colsResizableOpts <- list(resizeMode = "flex",
    #                          liveDrag = TRUE)
    colsResizableOpts <- list(resizeMode = "overflow",
                              liveDrag = TRUE,
                              postbackSafe = TRUE,
                              partialRefresh = TRUE,
                              removePadding = FALSE
    )
    d3tf(Test,
         tableProps = tableProps,
         extensions = extensions,
         edit = TRUE,
         tableStyle = "table table-bordered",
         colsResizable = TRUE,
         colsResizableOptions = colsResizableOpts);
  })

})

runApp(list(ui=ui,server=server))

1) Column resizing does not work when launching the Rshiny application via browser, but does seems to work when launching it locally in R-Studio. This seems to be a dataset specific issue, because it does work when I use mtcars dataset.

2) When launching in browser and trying to adjust column width of one of the larger columns (Column_Name = "Test15") it seems to be reacting oddly, and not following what I expect to happen from a resize option = "overflow". When resizing Column15 all other columns seems to scale as well, instead of just column 15 independently.