dreamRs / datamods

Shiny modules to import and manipulate data into an application or addin
https://dreamrs.github.io/datamods/
GNU General Public License v3.0
138 stars 35 forks source link

reset not working in import_copypaste_server() #75

Closed senthilcaesar closed 12 months ago

senthilcaesar commented 1 year ago

https://github.com/dreamRs/datamods/blob/50eb6e5b2bdc25e6009aff13f0c0bdfd3ed9ecbc/R/import-copypaste.R#L99

senthilcaesar commented 1 year ago

I have set the reset to trigger whenever I perform an upload data action. reset = reactive(input$upload) But the data still remains

pvictor commented 12 months ago

Hello, Reset will only work if trigger_return = "change", this is the mode where you have control over the data by using your own validate / reset button.

Example :

library(shiny)
library(datamods)

ui <- fluidPage(
  tags$h3("Import data with copy & paste"),
  fluidRow(
    column(
      width = 4,
      import_copypaste_ui("myid")
    ),
    column(
      width = 8,
      actionButton("reset", "Reset data"),
      tags$b("Data:"),
      verbatimTextOutput(outputId = "data")
    )
  )
)

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

  imported <- import_copypaste_server("myid", trigger_return = "change", reset = reactive(input$reset))
  output$data <- renderPrint({
    imported$data()
  })

}

shinyApp(ui, server)

Victor

senthilcaesar commented 12 months ago

Thank you so much @pvictor . In the future release, do you expect to apply the same behavior to trigger_return = "button"