Description Usage Arguments Value Author(s) Examples
dq_add_selectize_options adds selectizeOptions to a column of a rhandsontable to be used with the selectize editor. Especially useful if each cell should have individual dropdowns. It will also set the type and editor for the specified column.
dq_as_selectize_options converts the given vector of options into a proper selectize options list. Names of the given vector will be used to specify labels for the options. Further selectize attributes can be set via additional named parameters.
1 2 3 | dq_add_selectize_options(hot, rows, col, options, allowInvalid = FALSE, ...)
dq_as_selectize_options(options, ...)
|
hot |
rhandsontable object |
rows |
vector of row indices, NULL means the whole column will be filled |
col |
column index or name, must be scalar |
options |
character vector or list to be used as selectize options, names will be used as labels for the options, dq_add_selectize_options can also handle lists of vectors, where each vector will be used to specify the options of one cell |
allowInvalid |
logical specifying whether invalid data will be accepted |
... |
additional parameters to be passed to selectize |
dq_add_selectize_options: updated rhandsontable object
dq_as_selectize_options: list containing all options and additional settings
richard.kunze
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | ## Only run examples in interactive R sessions
if (interactive()) {
library(rhandsontable)
library(shiny)
hw <- c("Hello", "my", "funny", "world!",
"Those", "are", "some", "really", "random", "words!")
options <- lapply(1:10, function(x) c(Name1 = sample(hw, 1),
Name2 = sample(hw, 1), Name3 = sample(hw, 1)))
ch <- sample(hw, 3)
names(ch) <- sample(hw, 3)
selectize <- dq_as_selectize_options(ch, create = TRUE)
empty <- rep("", 10)
df <- data.frame(Unlabled=empty, Labled=empty,
Multiple=empty, stringsAsFactors = F)
shinyApp(
ui = fluidPage(
dq_space(),
rHandsontableOutput("randomTable")
),
server = function(input, output) {
output$randomTable <- renderRHandsontable({
rhandsontable(df, stretchH = "all") %>%
dq_add_selectize_options(NULL, 1, lapply(options, unname)) %>%
hot_col(2, editor = "selectize", selectizeOptions = selectize) %>%
dq_add_selectize_options(NULL, "Multiple", options, maxItems = 2)
})
}
)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.