Last active
November 15, 2018 14:49
-
-
Save davidarndt/bc09d77fa92457e094c8 to your computer and use it in GitHub Desktop.
Shiny fileInput reset using renderUI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shiny fileInput reset using renderUI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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%") | |
}) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
On Stack Overflow: http://stackoverflow.com/questions/17352086/how-can-i-update-a-shiny-fileinput-object/33271056#33271056