Skip to contents

Renders a datatable (from library DT)

Usage

render_datatable(
  output,
  ns = character(),
  i18n = character(),
  data = tibble::tibble(),
  output_name = character(),
  col_names = character(),
  datatable_dom = "<'datatable_length'l><'top't><'bottom'p>",
  page_length = 10,
  editable_cols = character(),
  sortable_cols = character(),
  centered_cols = character(),
  searchable_cols = character(),
  filter = FALSE,
  factorize_cols = character(),
  column_widths = character(),
  hidden_cols = character(),
  selection = "single",
  bold_rows = character(),
  shortened_cols = character()
)

Arguments

output

variable from Shiny, used to render messages on the message bar

ns

Shiny namespace

i18n

Translator object from shiny.i18n library

data

Data used in the datatable (tibble or dataframe)

output_name

Name of the datatable output

col_names

A character vector containing colnames, already translated (character)

datatable_dom

Character containing DOM code for the datatable (character)

page_length

Page length of the datatable, default to 10 rows (integer)

editable_cols

Which cols are editable (character vector)

sortable_cols

Which cols are sortable (character vector)

centered_cols

Which cols are centered (character vector)

searchable_cols

If filter is TRUE, choose which columns are searchable (character)

filter

If TRUE, we can filter with a textfield each column (logical)

factorize_cols

Which columns are factorized (to be filtered with a dropdown) (character)

column_widths

Columns widths (named character vector)

hidden_cols

Which cols are hidden (character vector)

selection

Can we select one or multiple rows ? ("single" or "multiple") (character)

bold_rows

Which cols are displayed with bold text (character vector)

shortened_cols

Which cols are shortened, and with how many characters (named vector)

Examples

if (FALSE) {
editable_cols <- c("name", "description", "url_address")
sortable_cols <- c("name", "creator_id", "datetime")
column_widths <- c("id" = "80px", "datetime" = "130px", "creator_id" = "200px", "action" = "80px", "category" = "130px")
centered_cols <- c("creator_id", "datetime", "action", "category")
searchable_cols <- c("name", "creator_id", "category")
factorize_cols <- c("creator_id", "category")
hidden_cols <- c("id", "deleted", "modified", "description")
col_names <- get_col_names("git_repos", i18n)
shortened_cols <- c("name" = 30, "url_address" = 30, "creator_id" = 20)
my_data <- tibble::tibble(col_1 = c("value_1", "value_2"), col_2 = c("value_3", "value_4"))

render_datatable(output = output, ns = ns, i18n = i18n, data = my_data,
  output_name = "git_repos_datatable", col_names = col_names, shortened_cols = shortened_cols,
  editable_cols = editable_cols, sortable_cols = sortable_cols, centered_cols = centered_cols, column_widths = column_widths,
  searchable_cols = searchable_cols, filter = TRUE, factorize_cols = factorize_cols, hidden_cols = hidden_cols)
}