Skip to content

Instantly share code, notes, and snippets.

@davidarndt
Last active November 15, 2018 14:49
Show Gist options
  • Save davidarndt/bc09d77fa92457e094c8 to your computer and use it in GitHub Desktop.
Save davidarndt/bc09d77fa92457e094c8 to your computer and use it in GitHub Desktop.
Shiny fileInput reset using renderUI
Shiny fileInput reset using renderUI
shinyServer(function(input, output, session) {
values <- reactiveValues(
file1 = NULL
)
observe({
input$clearFile1
input$uploadFormat
values$file1 <- NULL
})
observe({
values$file1 <- input$file1
})
output$summary <- renderText({
return(paste("Uploaded file: ", values$file1$name))
})
output$resettableInput <- renderUI({
input$clearFile1
input$uploadFormat
fileInput('file1', NULL, width="80%")
})
})
shinyUI(bootstrapPage(
tags$head(
tags$style(".clearButton {float:right; font-size:12px;}")
),
headerPanel("Reset file input example"),
sidebarPanel(
HTML("<button id='clearFile1' class='action-button clearButton'>Clear</button>"),
uiOutput('resettableInput'),
selectInput('uploadFormat', label = "Select upload format",
choices = c(
"Option 1" = 'f1',
"Option 2" = 'f2',
"Option 3" = 'f3'),
selected = 'f1')
),
mainPanel(
h4("Summary"),
verbatimTextOutput("summary")
)
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment