0

I try to create a drop-down list in the table, given a default value, and all possible options in the list, I would like to update the value in this way and update the data, and output a updated csv file.

This is my reproducible code:

library(shiny)
library(DT)

raw_all_dataset <- iris

shinyApp(

  ui <-  navbarPage("Modifier",
                    tabPanel("Dataset Level",

                             mainPanel(
                               fluidRow(
                                 tags$style(type='text/css', ".selectize-input { font-size: 12px; line-height: 12px;} .selectize-dropdown { font-size: 12px; line-height: 12px; }"),
                               ),
                               DT::dataTableOutput("output_dataset", width = "auto", height = "auto")
                             )
                    ),

                    theme = shinytheme("yeti")
  ),

  server <- function(input, output, session) {

    data1 <- raw_all_dataset

    for (i in 1:nrow(data1)) {
      data1$FRULE[i] <- as.character(selectInput("sel_data1", "", choices = c("Keep","Drop"), selected = "Keep"))
    }

    output$output_dataset = DT::renderDataTable(server = FALSE, DT::datatable(

    data1,

    style = 'jqueryui',

    extensions = 'Buttons',
    options = list(dom = 'Bfrtlip',buttons = list('copy', list(extend = 'collection', buttons = list(list(extend = 'csv', filename = "deid_all_dataset"),
                                                                                                     list(extend = 'excel', filename = "deid_all_dataset")), text = 'Save this report'))),

    escape = FALSE

    ) 

    )

  }

)

The difficulties I am facing is that the table is not updated simultaneously, the output csv shows that all options in the drop-down list were populated out in a same cell, rather than the wanted and the only wanted one in the cell......

enter image description here

Huan Lu
  • 15
  • 5
  • It's easier [with the CellEdit library](https://stackoverflow.com/a/60845695/1100107). – Stéphane Laurent May 08 '20 at 16:09
  • Thank you, Stephane, is it possible to inject CellEdit into Shiny UI, with color render and an output option button? – Huan Lu May 11 '20 at 03:45
  • Hi Stephane, I found your other post here: https://stackoverflow.com/questions/60999913/using-values-from-slider-in-javascript-datatables-calculations, I think my problem is almost solved, thank you very much! – Huan Lu May 11 '20 at 07:43

0 Answers0