I've deployed my first large modular app to our company's Rconnect server. Great.
Now, rightly 20 out of the 250 users are asking me why I did not include a save functionality for the fancy DT
datatables I've built for them.
I wanted to do provide both an html file via DT::saveWidget and a PNG to allow my users to use the tables in reports etc.
So, I used an actionbutton in the module's server side:
observeEvent( input$downloadFigure, {
dat_dat <- DT::datatable(dat)
DT::saveWidget(dat_dat, 'foo.html')
}
but that just saves the widget to my own working directory which is hosted on an S3 instance etc. How can I send the file 'foo.html' to the users' browser default save location?
Separately, is it possible to also create a png file with only the widget (i.e. not the remaining webpage?)
I already use the DT buttons to download data and pdfs with no formatting or complex color-coding but I need the entire form/structure not just the values.
@john_doe congrats that you have deployed your large app on RStudio Connect!
About downloading the html file to the user's browser location: you can use a downloadhandler for this. See below for an example how you could do this.
Thank you for your response. I implemented your suggestion but unfortunately the html file does not retain any of the colors/format of the table - which is the only reason I needed this solution. Wouldn't converting to PNG, SVG or PDF help with the datatable retaining the colors, and other elements?
I am not sure why it doesn't pick up the styling in your application. I have updated my example with a colored header, which does appear in the html file.