Description Usage Arguments See Also Examples
Change the value of a drop input on the client
1 | updateDropInput(session, inputId, selected = NULL, disabled = NULL)
|
session |
The |
inputId |
The id of the input object. |
selected |
The initially selected value. |
disabled |
Choices ( |
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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | if (interactive()) {
library(shiny)
library(esquisse)
myChoices <- tagList(
list(icon("home"), style = "width: 100px;"),
list(icon("flash"), style = "width: 100px;"),
list(icon("cogs"), style = "width: 100px;"),
list(icon("fire"), style = "width: 100px;"),
list(icon("users"), style = "width: 100px;"),
list(icon("info"), style = "width: 100px;")
)
ui <- fluidPage(
tags$h2("Update Drop Input"),
fluidRow(
column(
width = 6,
dropInput(
inputId = "mydrop",
choicesNames = myChoices,
choicesValues = c("home", "flash", "cogs", "fire", "users", "info"),
dropWidth = "220px"
),
verbatimTextOutput(outputId = "res")
),
column(
width = 6,
actionButton("home", "Select home"),
actionButton("flash", "Select flash"),
actionButton("cogs", "Select cogs"),
actionButton("fire", "Select fire"),
actionButton("users", "Select users"),
actionButton("info", "Select info"),
checkboxGroupInput(
inputId = "disabled",
label = "Choices to disable",
choices = c("home", "flash", "cogs", "fire", "users", "info")
),
actionButton("disable", "Disable")
)
)
)
server <- function(input, output, session) {
output$res <- renderPrint({
input$mydrop
})
observeEvent(input$home, {
updateDropInput(session, "mydrop", "home")
})
observeEvent(input$flash, {
updateDropInput(session, "mydrop", "flash")
})
observeEvent(input$cogs, {
updateDropInput(session, "mydrop", "cogs")
})
observeEvent(input$fire, {
updateDropInput(session, "mydrop", "fire")
})
observeEvent(input$users, {
updateDropInput(session, "mydrop", "users")
})
observeEvent(input$info, {
updateDropInput(session, "mydrop", "info")
})
observeEvent(input$disable, {
if (!is.null(input$disabled)) {
updateDropInput(session, "mydrop", disabled = input$disabled)
} else {
updateDropInput(session, "mydrop", disabled = character(0))
}
})
}
shinyApp(ui, server)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.