Reputation: 1968
In my Shiny app, I run calculations, generate a data frame, and want the user to be able to save (download) it.
My relevant code in ui.R:
textInput("downFile","Save the File:", value = "Results File"),
downloadButton('downFile',"Save File"),
My relevant code in server.R:
output$downFile <- downloadHandler(
filename = function() {
paste0(input$downFile, " ", Sys.Date(), ".csv")
},
content = function(file) {
write.csv(MyMainFunction()$mydataframe, file, row.names = FALSE)
}
)
Everything works. But I have two issues:
Two questions:
Is it possible to make the button invisible until the calculations in my main function (MainFunction) are completed?
How could I allow the user to select a desired folder to download the results to? (as in "Save in...")
Thank you very much!
Upvotes: 2
Views: 1267
Reputation: 1506
for question 1: Use shinyjs package learn more in https://deanattali.com/shinyjs/
library(shinyjs)
disable("downFile") # or use hide() Before all calculations
enable("downFile") # or use show() After
For question 2: I think this is more about setting up your browser than the shiny
If you are using chrome go to the advanced settings and enable
Upvotes: 2