regexSelectUI: Create UI object for a selectize list input control with...

Description Usage Arguments Details Value Examples

View source: R/regexSelectUI.R

Description

Create UI object for a selectize list that can be used to choose a single or multiple items from a list of values with extension for regular expression.

Usage

1
2
regexSelectUI(id, label, choices, checkbox.selected = c("enable",
  "ignore.case"), checkbox.inline = TRUE, checkbox.show = FALSE)

Arguments

id

id of shiny module used in regexSelect

label

character, label of the selectize object

choices

List of values to select from. If elements of the list are named, then that name rather than the value is displayed to the user. This can also be a named list whose elements are (either named or unnamed) lists or vectors. If this is the case, the outermost names will be used as the "optgroup" label for the elements in the respective sublist. This allows you to group and label similar choices.

checkbox.selected

character, options of the checkbox to set as TRUE, see details, Default: c("enable", "ignore.case")

checkbox.inline

boolean, render the checkbox choices inline (i.e. horizontally), Default: TRUE

checkbox.show

boolean, show the checkbox options as part of UI output or hide them, Default: FALSE

Details

checkbox.selected is used as a proxy for ellipses to pass arguments to a grep(selectize value, selectize choices,value=TRUE,...). This makes the options in checkbox.selected the same as the arguments that pass to grep: ignore.case, perl,fixed and invert.

In addition there are two more arguments that the user can set enable which toggles the grep functionality to return it to regular selectize with options multiple=TRUE and create=TRUE. The other argument is retain, this lets the user control if the search terms are added to the selectize choices or to keep it as originally entered, there by converting the selectize into a search field. If checkbox.show is false the initial values passed through checkbox.selected will be used.

Value

A list of HTML elements that can be added to a UI definition.

Examples

 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
if(interactive()){
ui <- shiny::fluidPage(
regexSelectUI(id = "a", label = "Variable:",choices = names(iris)),
shiny::tableOutput("data")
)


ui.show <- shiny::fluidPage(
regexSelectUI(id = "a", label = "Variable:",choices = names(iris),checkbox.show = TRUE),
shiny::tableOutput("data")
)

server <- function(input, output, session) {
 curr_cols<-shiny::callModule(regexSelect, "a",shiny::reactive(names(iris)))
 
 shiny::observeEvent(curr_cols(),{
 cols_now<-curr_cols()
 if(length(cols_now)==0)  cols_now<-names(data())
 output$data <- shiny::renderTable({iris[,cols_now , drop = FALSE]}, rownames = TRUE)
 })
}

#do not show regex checkboxes
shiny::shinyApp(ui, server)

#show regex checkboxes
shiny::shinyApp(ui.show, server)
 }

regexSelect documentation built on May 1, 2019, 10:56 p.m.