Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Kuethe committed Sep 13, 2024
1 parent 4908ef2 commit 9a7d959
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 32 deletions.
1 change: 0 additions & 1 deletion R/columns.R
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ set_formatter_star <- function(widget, column, number_of_stars, hoz_align = "cen
#' If set to \code{NA} the minimum value of the column is used.
#' @param max (numeric): The maximum value for progress bar.
#' If set to \code{NA} the maximum value of the column is used.
#' @param max description
#' @param color (character): Either a single color or a vector of colors
#' @param legend (character, \code{TRUE}, JavaScript function): If set to \code{TRUE} the value of the cell is displayed.
#' Set to \code{NA} to display no value at all.
Expand Down
25 changes: 25 additions & 0 deletions R/spreadsheet.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## #' @export
# TODO: Is this useful?
set_spreadsheet_mode <- function(
widget,
spreadsheet_rows = NULL,
spreadsheet_columns = NULL,
spreadsheet_column_definition = NULL,
spreadsheet_sheets = NULL,
spreadsheet_sheet_tabs = NULL,
...) {
spreadsheet_options <- list(
spreadsheet = TRUE,
spreadsheetRows = spreadsheet_rows,
spreadsheetColumns = spreadsheet_columns,
spreadsheetColumnDefinition = spreadsheet_column_definition,
spreadsheetSheets = spreadsheet_sheets,
spreadsheetSheetTabs = spreadsheet_sheet_tabs,
...
)
widget$x$options <- keys_to_camel_case(utils::modifyList(
utils::modifyList(widget$x$options, default_spreadsheet_options),
compact(spreadsheet_options)
))
return(widget)
}
4 changes: 2 additions & 2 deletions R/tabulator.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#' @param theme (character): Theme to apply to the table.
#' @param width Width of the widget.
#' @param height Height of the widget.
#' @param element_id description
#' @param element_id The unique ID of the widget.
#' @param ... Named arguments that are appended to the \code{options} parameter.
#' @import htmlwidgets
#' @export
Expand All @@ -36,7 +36,7 @@ tabulator <- function(
if (isTRUE(options$spreadsheet)) {
# ...
options <- utils::modifyList(default_spreadsheet_options, options)
} else {
} else if (is.data.frame(data)) {
data <- fix_colnames(data)
if (getOption("rtabulator.auto_columns", TRUE) && is.null(options$columns)) {
options$columns <- create_columns(data, editor = editable)
Expand Down
33 changes: 20 additions & 13 deletions R/tabulator_options.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,21 @@
#' @param frozen_rows (numeric): Number of frozen rows.
#' @param index (character): Field to be used as the unique index for each row.
#' @param group_by (character): Field to group rows by.
#' @param edit_trigger_event description
#' @param selectable_rows description
#' @param pagination (bool): description
#' @param pagination_size (integer): description
#' @param pagination_add_row (character): description
#' @param spreadsheet (bool): description
#' @param spreadsheet_rows (integer): description
#' @param spreadsheet_columns (integer): description
#' @param spreadsheet_column_definition description
#' @param spreadsheet_sheets (list): description
#' @param spreadsheet_sheet_tabs (bool): description
#' @param edit_trigger_event (character): Event that triggers a cell edit.
#' @param selectable_rows (character, bool, integer) Set to \code{FALSE} to disble row selection.
#' If set to \code{TRUE} you can select as many rows as you want.
#' If set to \code{"highlight"} rows are just highlighted but do not change state when clicked.
#' An integer value sets the maximum number of rows that can be selected.
#' @param pagination (bool): Whether to enable pagination.
#' @param pagination_size (integer): Number of rows on each page.
#' @param pagination_size_selector (list): Add pagination size selector.
#' @param pagination_add_row (character): Where to add rows to the table when pagination is enabled.
#' @param spreadsheet (bool): Whether to enable spreadsheet mode.
#' @param spreadsheet_rows (integer): Number of spreadsheet rows.
#' @param spreadsheet_columns (integer): Number of spreadsheet columns.
#' @param spreadsheet_column_definition Column definition used for all columns in the sheet.
#' @param spreadsheet_sheets (list): List of sheet definitions.
#' @param spreadsheet_sheet_tabs (bool): Whether to show sheet tabs in the footer.
#' @param ... Further options.
#' @seealso \url{https://tabulator.info/docs/6.2/options}
#' @export
Expand All @@ -50,13 +54,14 @@ tabulator_options <- function(
# Row Grouping
group_by = NULL,
# Editing
edit_trigger_event = "dblclick",
edit_trigger_event = c("dblclick", "click", "focus"),
# Selection
selectable_rows = "highlight", # 'highlight', bool or integer
# Pagination
pagination = FALSE,
pagination_size = 10,
pagination_add_row = "page",
pagination_size_selector = FALSE,
pagination_add_row = c("page", "table"),
# Spreadsheet
spreadsheet = FALSE,
spreadsheet_rows = NULL,
Expand All @@ -68,6 +73,8 @@ tabulator_options <- function(
params <- as.list(environment())
params$layout <- match.arg(layout)
params$add_row_pos <- match.arg(add_row_pos)
params$edit_trigger_event <- match.arg(edit_trigger_event)
params$pagination_add_row <- match.arg(pagination_add_row)
return(c(params, list(...)))
}

Expand Down
3 changes: 2 additions & 1 deletion man/set_formatter_progress.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion man/set_formatter_traffic_light.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/tabulator.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 19 additions & 13 deletions man/tabulator_options.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9a7d959

Please sign in to comment.