| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/update-input.R |
| 3 |
\name{updateCheckboxGroupInput} |
| 4 |
\alias{updateCheckboxGroupInput} |
| 5 |
\title{Change the value of a checkbox group input on the client} |
| 6 |
\usage{ |
| 7 |
updateCheckboxGroupInput( |
| 8 |
session = getDefaultReactiveDomain(), |
| 9 |
inputId, |
| 10 |
label = NULL, |
| 11 |
choices = NULL, |
| 12 |
selected = NULL, |
| 13 |
inline = FALSE, |
| 14 |
choiceNames = NULL, |
| 15 |
choiceValues = NULL |
| 16 |
) |
| 17 |
} |
| 18 |
\arguments{ |
| 19 |
\item{session}{The \code{session} object passed to function given to |
| 20 |
\code{shinyServer}. Default is \code{getDefaultReactiveDomain()}.} |
| 21 |
|
| 22 |
\item{inputId}{The id of the input object.} |
| 23 |
|
| 24 |
\item{label}{The label to set for the input object.} |
| 25 |
|
| 26 |
\item{choices}{List of values to show checkboxes for. If elements of the list |
| 27 |
are named then that name rather than the value is displayed to the user. If |
| 28 |
this argument is provided, then \code{choiceNames} and \code{choiceValues} |
| 29 |
must not be provided, and vice-versa. The values should be strings; other |
| 30 |
types (such as logicals and numbers) will be coerced to strings.} |
| 31 |
|
| 32 |
\item{selected}{The values that should be initially selected, if any.} |
| 33 |
|
| 34 |
\item{inline}{If \code{TRUE}, render the choices inline (i.e. horizontally)} |
| 35 |
|
| 36 |
\item{choiceNames, choiceValues}{List of names and values, respectively, |
| 37 |
that are displayed to the user in the app and correspond to the each |
| 38 |
choice (for this reason, \code{choiceNames} and \code{choiceValues} |
| 39 |
must have the same length). If either of these arguments is |
| 40 |
provided, then the other \emph{must} be provided and \code{choices} |
| 41 |
\emph{must not} be provided. The advantage of using both of these over |
| 42 |
a named list for \code{choices} is that \code{choiceNames} allows any |
| 43 |
type of UI object to be passed through (tag objects, icons, HTML code, |
| 44 |
...), instead of just simple text. See Examples.} |
| 45 |
} |
| 46 |
\description{ |
| 47 |
Change the value of a checkbox group input on the client |
| 48 |
} |
| 49 |
\details{ |
| 50 |
The input updater functions send a message to the client, telling it to |
| 51 |
change the settings of an input object. The messages are collected and sent |
| 52 |
after all the observers (including outputs) have finished running. |
| 53 |
|
| 54 |
The syntax of these functions is similar to the functions that created the |
| 55 |
inputs in the first place. For example, \code{\link{numericInput}()} and |
| 56 |
\code{updateNumericInput()} take a similar set of arguments. |
| 57 |
|
| 58 |
Any arguments with NULL values will be ignored; they will not result in any |
| 59 |
changes to the input object on the client. |
| 60 |
|
| 61 |
For \code{\link{radioButtons}()}, \code{\link{checkboxGroupInput}()} and |
| 62 |
\code{\link{selectInput}()}, the set of choices can be cleared by using |
| 63 |
\code{choices=character(0)}. Similarly, for these inputs, the selected item |
| 64 |
can be cleared by using \code{selected=character(0)}. |
| 65 |
} |
| 66 |
\examples{ |
| 67 |
## Only run examples in interactive R sessions |
| 68 |
if (interactive()) { |
| 69 |
|
| 70 |
ui <- fluidPage( |
| 71 |
p("The first checkbox group controls the second"), |
| 72 |
checkboxGroupInput("inCheckboxGroup", "Input checkbox", |
| 73 |
c("Item A", "Item B", "Item C")), |
| 74 |
checkboxGroupInput("inCheckboxGroup2", "Input checkbox 2", |
| 75 |
c("Item A", "Item B", "Item C")) |
| 76 |
) |
| 77 |
|
| 78 |
server <- function(input, output, session) { |
| 79 |
observe({ |
| 80 |
x <- input$inCheckboxGroup |
| 81 |
|
| 82 |
# Can use character(0) to remove all choices |
| 83 |
if (is.null(x)) |
| 84 |
x <- character(0) |
| 85 |
|
| 86 |
# Can also set the label and select items |
| 87 |
updateCheckboxGroupInput(session, "inCheckboxGroup2", |
| 88 |
label = paste("Checkboxgroup label", length(x)), |
| 89 |
choices = x, |
| 90 |
selected = x |
| 91 |
) |
| 92 |
}) |
| 93 |
} |
| 94 |
|
| 95 |
shinyApp(ui, server) |
| 96 |
} |
| 97 |
} |
| 98 |
\seealso{ |
| 99 |
\code{\link[=checkboxGroupInput]{checkboxGroupInput()}} |
| 100 |
} |