dreamRs / toastui

R htmlwidgets for ToastUI libraries: grid, calendar and chart
https://dreamrs.github.io/toastui
Other
82 stars 8 forks source link

datagrid(..., filters = T) does not add filters to boolean columns by default #35

Closed scconner7 closed 1 year ago

scconner7 commented 1 year ago

Issue Description: Simply setting filters = T within datagrid() does not add a filter icon and filter features to boolean columns by default. Filters must be explicitly added to boolean columns using grid_filters().

The simple reprex app and the screenshot taken from it below illustrate the problematic behavior and how filters must currently be added to boolean columns.

image

if (interactive()) {
  library(shiny)
  library(toastui)

  ui <- fluidPage(column(
    6,
    tags$h2(
      "datagrid(..., filters = T) does not add filters to boolean columns by default"
    ),
    datagridOutput("grid1")
  ),
  column(
    6,
    tags$h2("one must add filters to boolean columns explicitly using grid_filters()"),
    datagridOutput("grid2")
  ))

  server <- function(input, output, session) {
    df <- data.frame(
      index = 1:12,
      month = month.name,
      letters = letters[1:12],
      bool = c(rep(T, 6), rep(F, 6))
    )

    output$grid1 <- renderDatagrid({
      datagrid(df, filters = T)
    })

    output$grid2 <- renderDatagrid({
      datagrid(df, filters = T) %>%
        grid_filters(columns = "bool", type = "select")
    })
  }

  shinyApp(ui, server)
}

Desired Resolution: Setting filters = T within datagrid() should properly add a filter icon and filter functionality to boolean columns as well.

pvictor commented 1 year ago

Thanks for reporting this, if re-install from GitHub filters are now set for logical columns.

Victor