I am trying to give the user the option to look at a subset of a data table, reorder that subset with RowReorders drag and drop function, then then export that now reordered data to a file.
I have the subset view and the drag and drop working and I know how to write.table, my issue is that write table works on a data frame and not on my rendered table im allowing my user to reorder.
How do I print my reordered table?
Here is my RowReorder code if it helps:
output$dtable <- renderDT(server=FALSE,{ datatable( downloadsubset(), colnames=c(ID = 1), extensions ='RowReorder',options=list( order=list(list(0,'asc')), rowReorder=TRUE, iDisplayLength=25, columnDefs=list(list(className="nowrap", targets="_all" ) )))})
and my download code:
#what happenes when you press the download button
output$download_file <- downloadHandler(
#set the file name, here it is "Download" then the date then .txt
filename = function() { paste0("Download", gsub(":", "-", Sys.time()),".txt")},
#set what will be downloaded, here it is the data from the reactive value downloadsubset
content = function(file) { write.table(downloadsubset(),file, row.names = FALSE, na="", sep="t", quote=FALSE) }
)
I have tried passing the table itself to write.table but that did not work. Is there a way to capture the data in the rendered table, save it to a new data.table, and then export THAT?
I need the data from the reordered table which the user is manipulating to be able to be exported.
Thanks!