I am working on a shiny app that creates a datatable to be edited and saved as a dataframe object globaly.
The problem i am facing is: the dataframe as a dropdowm menu option - the name
column. When the dataframe is saved, the output is the as.character
output. Example below:
library(shiny)
ui <- fluidPage(
DT::dataTableOutput("shinytest")
)
server <- function(input, output) {
df <- data.frame(Number = NA,
Pages = NA,
Name = as.character(selectInput(paste0("sel", 1), "", choices = c("x","y"), width = "100px"))
)
rv <- reactiveVal(df)
output$shinytest <- DT::renderDataTable ({
DT::datatable(rv(), editable = TRUE, escape = FALSE, selection = 'none'
)
})
observeEvent(input$shinytest_cell_edit, {
info <- input$shinytest_cell_edit
newdf <- rv()
newdf[info$row, info$col] <- info$value
rv(newdf)
x <<- rv()
})
}
shinyApp(ui, server)
for x in the global environment: under the column name I get: <div class="form-group shiny-input-container" style="width:100px;">\n <label class="control-label" id="sel1-label" for="sel1"></label>\n <div>\n <select id="sel1"><option value="x" selected>x</option>\n<option value="y">y</option></select>\n <script type="application/json" data-for="sel1" data-nonempty="">{"plugins":["selectize-plugin-a11y"]}</script>\n </div>\n</div>
Building on the code found in this post by @GyD
Any assistance is appreciated.