Skip to contents

Set options for one or several specific column.

Usage

grid_columns(
  grid,
  columns,
  header = NULL,
  ellipsis = NULL,
  align = NULL,
  valign = NULL,
  className = NULL,
  width = NULL,
  minWidth = NULL,
  hidden = NULL,
  resizable = NULL,
  defaultValue = NULL,
  formatter = NULL,
  escapeHTML = NULL,
  ignored = NULL,
  sortable = NULL,
  sortingType = NULL,
  onBeforeChange = NULL,
  onAfterChange = NULL,
  whiteSpace = NULL,
  ...
)

Arguments

grid

A grid created with datagrid().

columns

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

header

The header of the column to be shown on the header.

ellipsis

If set to true, ellipsis will be used for overflowing content.

align

Horizontal alignment of the column content. Available values are 'left', 'center', 'right'.

valign

Vertical alignment of the column content. Available values are 'top', 'middle', 'bottom'.

className

The name of the class to be used for all cells of the column.

width

The width of the column. The unit is pixel. If this value isn't set, the column's width is automatically resized.

minWidth

The minimum width of the column. The unit is pixel.

hidden

If set to true, the column will not be shown.

resizable

If set to false, the width of the column will not be changed.

defaultValue

The default value to be shown when the column doesn't have a value.

formatter

The function that formats the value of the cell. The return value of the function will be shown as the value of the cell. If set to 'listItemText', the value will be shown the text.

escapeHTML

If set to true, the value of the cell will be encoded as HTML entities.

ignored

If set to true, the value of the column will be ignored when setting up the list of modified rows.

sortable

If set to true, sort button will be shown on the right side of the column header, which executes the sort action when clicked.

sortingType

If set to 'desc', will execute descending sort initially when sort button is clicked. Default to 'asc'.

onBeforeChange

The function that will be called before changing the value of the cell. If stop() method in event object is called, the changing will be canceled.

onAfterChange

The function that will be called after changing the value of the cell.

whiteSpace

If set to 'normal', the text line is broken by fitting to the column's width. If set to 'pre', spaces are preserved and the text is broken by new line characters. If set to 'pre-wrap', spaces are preserved, the text line is broken by fitting to the column's width and new line characters. If set to 'pre-line', spaces are merged, the text line is broken by fitting to the column's width and new line characters.

...

Additional parameters.

Value

A datagrid htmlwidget.

Note

Documentation come from https://nhn.github.io/tui.grid/latest/Grid/.

Examples

library(toastui)

# New header label
datagrid(mtcars[, 1:5]) %>%
  grid_columns(columns = "mpg", header = "Miles/(US) gallon")
# Align content to right & resize datagrid(mtcars[, 1:5]) %>% grid_columns( columns = "mpg", align = "left", resizable = TRUE ) %>% grid_columns( columns = "cyl", align = "left", resizable = TRUE )
# Hide a column datagrid(mtcars[, 1:5]) %>% grid_columns( columns = "mpg", hidden = TRUE )
# Set options for 2 columns datagrid(mtcars[, 1:5]) %>% grid_columns( columns = c("mpg", "cyl"), header = c("Miles/(US) gallon", "Number of cylinders") )