Skip to contents

Set filters options

Usage

grid_filters(
  grid,
  columns,
  showApplyBtn = NULL,
  showClearBtn = NULL,
  operator = NULL,
  format = "yyyy-MM-dd",
  type = "auto"
)

Arguments

grid

A table created with datagrid().

columns

Name(s) of column in the data used in datagrid().

showApplyBtn

Apply filters only when button is pressed.

showClearBtn

Reset the filter that has already been applied.

operator

Multi-option filter, the operator used against multiple rules : "OR" or "AND".

format

Date format.

type

Type of filter : "auto", "text", "number", "date" or "select".

Value

A datagrid htmlwidget.

Examples

library(toastui)

data <- data.frame(
  number = 1:12,
  month.abb = month.abb,
  month.name = month.name,
  date = Sys.Date() + 0:11,
  stringsAsFactors = FALSE
)

datagrid(data) %>%
  grid_filters(
    columns = "month.abb",
    showApplyBtn = TRUE,
    showClearBtn = TRUE,
    type = "text"
  ) %>%
  grid_filters(
    columns = "month.name",
    type = "select"
  ) %>%
  grid_filters(columns = "date") %>%
  grid_filters(columns = "number")
#> Warning: number of items to replace is not a multiple of replacement length
# Filter all variables datagrid(rolling_stones_500) %>% grid_filters(columns = names(rolling_stones_500))
# or datagrid(rolling_stones_500, filters = TRUE)