Commit ff56bd21 authored by biohentze's avatar biohentze

Add download button, UI tweaks

parent 7bfdf655
......@@ -179,11 +179,11 @@ ui <- dashboardPage(
id = "tabs",
tabPanel(
## Output : Data file
h3('Data'),
h4('Data'),
DTOutput("dataTable")
),
tabPanel(
h3('Image 2'),
h4('Image 2'),
box(
title = "Image 2", solidHeader = TRUE, status = "primary",
withSpinner(
......@@ -203,6 +203,7 @@ ui <- dashboardPage(
column(12,
box( width = 12,
title = "Editable data", solidHeader = TRUE, status = "primary",
downloadButton("download1","Download as csv"),
withSpinner(
DTOutput("dataTableEdit")
)
......@@ -410,20 +411,20 @@ server <- function(input, output, session) {
datatable(rv$data[rv$currentRows,],
class = 'row-border hover',
selection = list(mode = 'multiple', selected = rv$selectedRows),
extensions = c('FixedHeader', 'Buttons'),
extensions = c('Buttons', 'Scroller'),
filter = "top",
escape = FALSE, # Don't escape HTML code in the table to allow e.g. checkboxes
options = list(displayModeBar = TRUE,
fixedHeader = TRUE,
scrollX = TRUE,
scrollY = 1000,
scroller = TRUE,
stateSave = TRUE,
columnDefs = list(list(visible = FALSE, targets = rv$colsToHide)),
searchCols = defaultSearchColumns,
search = list(regex = FALSE, caseInsensitive = FALSE, search = defaultSearch),
autoWidth = TRUE,
lengthMenu = c(10, 25, 50, 100, 500, 1000),
dom = 'Bfrtip',
buttons = list('pageLength',
buttons = list(
list(
extend = 'collection',
text = 'Show filtered rows in plot',
......@@ -726,29 +727,37 @@ server <- function(input, output, session) {
datatable(rv$data[rv$currentRows,],
class = 'row-border hover',
selection = list(mode = 'multiple', selected = rv$selectedRows),
extensions = c('FixedHeader', 'Buttons'),
extensions = c('Scroller'),
editable = list(target = "cell", disable = list(columns = nonEditableColumns)),
filter = "top",
escape = FALSE, # Don't escape HTML code in the table to allow e.g. checkboxes
options = list(displayModeBar = TRUE,
fixedHeader = TRUE,
scrollX = TRUE,
scrollY = 1000,
scroller = TRUE,
stateSave = TRUE,
columnDefs = list(list(visible = FALSE, targets = rv$colsToHide)),
searchCols = defaultSearchColumns,
search = list(regex = FALSE, caseInsensitive = FALSE, search = defaultSearch),
autoWidth = TRUE,
lengthMenu = c(10, 25, 50, 100, 500, 1000),
dom = 'Bfrtip',
buttons = c('copy', 'csv')
dom = '<"dwnld">frtip'
)) %>%
formatStyle( 0, target= 'row', lineHeight='60%')
}, server = TRUE) # Server side processing required for large data tables
}, callback = DT::JS("$('div.dwnld').append($('#download1'));"), # works but generates warnings
server = TRUE) # Server side processing required for large data tables
observeEvent(input$dataTableEdit_cell_edit, {
rv$data <<- editData(rv$data, input$dataTableEdit_cell_edit, 'dataTableEdit')
})
output$download1 <- downloadHandler(
filename = function() {
basename(input$datafile$name)
},
content = function(file) {
write.csv(rv$data, file)
}
)
## Stop the app when browser tab is closed
session$onSessionEnded(stopApp)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment