Learn R Programming

toastui (version 0.4.0)

grid_filters: Set filters options

Description

Set filters options

Usage

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

Value

A datagrid htmlwidget.

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".

Examples

Run this code
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")


# Filter all variables
datagrid(rolling_stones_500) %>%
  grid_filters(columns = names(rolling_stones_500))
# or
datagrid(rolling_stones_500, filters = TRUE)

Run the code above in your browser using DataLab