-
Notifications
You must be signed in to change notification settings - Fork 157
/
Copy pathpicker-limits.R
54 lines (46 loc) · 1.29 KB
/
picker-limits.R
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
### Limit the number of selections ----
if (interactive()) {
library(shiny)
library(shinyWidgets)
ui <- fluidPage(
pickerInput(
inputId = "groups",
label = "Select one from each group below:",
choices = list(
Group1 = c("1", "2", "3", "4"),
Group2 = c("A", "B", "C", "D")
),
multiple = TRUE,
options = list("max-options-group" = 1)
),
verbatimTextOutput(outputId = "res_grp"),
pickerInput(
inputId = "groups_2",
label = "Select two from each group below:",
choices = list(
Group1 = c("1", "2", "3", "4"),
Group2 = c("A", "B", "C", "D")
),
multiple = TRUE,
options = list("max-options-group" = 2)
),
verbatimTextOutput(outputId = "res_grp_2"),
pickerInput(
inputId = "classic",
label = "Select max two option below:",
choices = c("A", "B", "C", "D"),
multiple = TRUE,
options = list(
"max-options" = 2,
"max-options-text" = "No more!"
)
),
verbatimTextOutput(outputId = "res_classic")
)
server <- function(input, output) {
output$res_grp <- renderPrint(input$groups)
output$res_grp_2 <- renderPrint(input$groups_2)
output$res_classic <- renderPrint(input$classic)
}
shinyApp(ui, server)
}