-
Notifications
You must be signed in to change notification settings - Fork 13
Defining default selected values for form controls
Suppose we have a dropdown list, checkbox group or multi-select list in an RCAP dashboard which gets its values from an R function in the notebook. There are currently two ways of defining default selected control values.
We can define defaults by returning our values in a list.
# Cell 1
getVals <<- function(){
list(value = c("potatoes", "tomatoes", "plums"),
selected = c("plums", "tomatoes"))
}
We must always return our values as a list with the names value
and selected
. selected
represents the defaults. In this case, the default selected values will be "plums"
and "tomatoes"
.
The other option is to define a default variable which has the same variable name as defined in our form control (this always defaults to variable
, which is what we use here for demonstrative purposes).
# Cell 1
variable <<- c("plums", "tomatoes")
Then we define our function which returns an unnamed vector of values.
# Cell 2
getVals <<- function(){
values <- c("potatoes", "tomatoes", "plums")
}
In this case, the default selected value will again be "plums"
and "tomatoes"
.
RCAP - RCloud powered dashboards and websites