Column definition utility
column_def.RdNeeded by cheetah to customize columns individually.
Usage
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
)Arguments
- name
Custom name.
- width
Column width.
- min_width
Column minimal width.
- max_width
Column max width.
- column_type
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. Ifcolumn_type == "menu", action parameter must be set to "inline_menu" and menu_options must be provided. Note: Works efficiently only in shiny.
- action
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 withvalueandlabelelements. The menu options must be a list of lists, each containing avalueandlabelelement. Thelabelelement is the label that will be displayed in the menu.- style
Column style.
- message
Cell message. Expect a
htmlwidgets::JS()function that takesrecas argument. It must return an object with two properties:typefor the message type ("info","warning","error") and themessagethat holds the text to display. The latter can leverage a JavaScript ternary operator involvingrec.<COLNAME>(COLNAMEbeing the name of the column for which we define the message) to check whether the predicate function is TRUE. You can also useadd_cell_message()to generated the expected JS expression. See details for example of usage.- sort
Whether to sort the column. Default to FALSE. May also be a JS callback to create custom logic (does not work yet).
Details
Cell messages
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.