Create interactive tables : sortable, filterable, editable with the JavaScript library tui-grid.
Arguments
- data
A
data.frame
or something convertible indata.frame
.- ...
Arguments passed to the
Grid
JavaScript method.- sortable
Logical, allow to sort columns.
- pagination
Number of rows per page to display, default to
NULL
(no pagination).- filters
Logical, allow to filter columns.
- colnames
Alternative colnames to be displayed in the header.
- colwidths
Width for the columns, can be
"auto"
(width is determined by column's content) or a single or numeric vector to set the width in pixel. UseNULL
to disable and use default behavior.- align
Alignment for columns content:
"auto"
(numeric and date on right, other on left),"right"
,"center"
or"left"
. UseNULL
to ignore.- theme
Predefined theme to be used.
- draggable
Whether to enable to drag the row for changing the order of rows.
- data_as_input
Should the
data
be available in an inputinput$<ID>_data
server-side?- contextmenu
Display or not a context menu when using right click in the grid. Can also be a list of custom options, see tui-grid documentation for examples.
- width, height
Width and height of the table in a CSS unit or a numeric.
- elementId
Use an explicit element ID for the widget.
See also
datagridOutput()
/ renderDatagrid()
for usage in Shiny applications.
Examples
library(toastui)
# default usage
datagrid(rolling_stones_50)
# Column's width alternatives (default is "fit")
datagrid(rolling_stones_50, colwidths = "guess")
datagrid(rolling_stones_50, colwidths = "auto")
datagrid(rolling_stones_50, colwidths = NULL)
# disable sorting
datagrid(rolling_stones_50, sortable = FALSE)
# enable default filtering
datagrid(rolling_stones_50, filters = TRUE)
# enable pagination (10 rows per page)
datagrid(rolling_stones_50, pagination = 10)
# Themes
datagrid(rolling_stones_50, theme = "striped")
datagrid(rolling_stones_50, theme = "default")
# Empty table
datagrid(list())
# Empty columns
datagrid(data.frame(
variable_1 = character(0),
variable_2 = character(0)
))
# Specify colnames
datagrid(
data = data.frame(
variable_1 = sample(1:50, 12),
variable_2 = month.name
),
colnames = c("Number", "Month of the year")
)