I have the following shiny app.
# GLOBAL ----
library(shiny)
library(DT)
library(readr)
library(dplyr)
SELECT = '<select year="" id="year-select">
<option value="">--Please choose an option--</option>
<option value="2014">2014</option>
<option value="2015">2015</option>
<option value="2016">2016</option>
</select>'
test_cars <- data.frame("Num" = c(1:5),
"Make" = c("Toyota","","","",""),
"Model" = c("Camry","","","",""))
test_cars$Year <- SELECT
# UI ----
ui <- navbarPage(
title = 'Cars Editor',
tabPanel("Cars Entry",DTOutput("table1")),
tabPanel("About")
)
# SERVER ----
server <- function(input, output) {
output$table1 <- renderDT({
datatable(test_cars %>% select(!Num), editable = "all", escape = FALSE, extensions = 'Buttons',
options = list(
dom = 'Bfrtip',
buttons =
list('copy', 'print', list(
extend = 'collection',
buttons = c('csv', 'excel', 'pdf'),
text = 'Download'
))
)
)
})
}
# Run app ----
shinyApp(ui = ui, server = server)
And this gives me the following: My goal is for the users to select an input from the "Year" column and have it be saved to the data.
But when I click download, I get all the options that were in the html select input and not the user's selection. Any thoughts on how I should approach this?