Needed by cheetah to customize columns individually.
column_def(
name = NULL,
width = NULL,
min_width = NULL,
max_width = NULL,
column_type = NULL,
action = NULL,
menu_options = NULL,
style = NULL,
message = NULL,
sort = FALSE
)A list of column options to pass to the JavaScript API.
Custom name.
Column width.
Column minimal width.
Column max width.
Column type. By default, the column type is inferred from the data type of the column. There are 7 possible options:
"text" for text columns.
"number" for numeric columns.
"check" for check columns.
"image" for image columns.
"radio" for radio columns.
"multilinetext" for multiline text columns.
"menu" for menu selection columns. If column_type == "menu",
action parameter must be set to "inline_menu" and menu_options must be provided.
Note: Works efficiently only in shiny.
The action property defines column actions. Select the appropriate Action class for the column type.
"input" for input action columns.
"check" for check action columns.
"radio" for radio action columns.
"inline_menu" for menu selection columns.
A list of menu options when using column_type = "menu".
Each option should be a list with value and label elements.
The menu options must be a list of lists, each containing a value
and label element.
The label element is the label that will be displayed in the menu.
Column style.
Cell message. Expect a htmlwidgets::JS() function that
takes rec as argument. It must return an object with two properties: type for the message
type ("info", "warning", "error") and the message that holds the text to display.
The latter can leverage a JavaScript ternary operator involving rec.<COLNAME> (COLNAME being the name
of the column for which we define the message) to check whether the predicate function is TRUE. You can also
use add_cell_message() to generated the expected JS expression.
See details for example of usage.
Whether to sort the column. Default to FALSE. May also be a JS callback to create custom logic (does not work yet).
When you write a message, you can pass a function like so:
<COLNAME> = column_def(
action = "input",
message = JS(
"function(rec) {
return {
//info message
type: 'info',
message: rec.<COLNAME> ? null : 'Please check.',
}
}")
)
Or use add_cell_message():
<COLNAME> = column_def(
action = "input",
message = add_cell_message(type = "info", message = "Ok")
)
See add_cell_message() for more details.
cheetah(
iris,
columns = list(
Sepal.Length = column_def(name = "Length"),
Sepal.Width = column_def(name = "Width"),
Petal.Length = column_def(name = "Length"),
Petal.Width = column_def(name = "Width")
)
)
Run the code above in your browser using DataLab