0
votes

i use app.

ui.R

shinyUI(
  fluidPage(
    actionButton("clear_ui", "clear_ui"),
    actionButton("clear_date", "clear_date"),
    uiOutput("date_ui"),
    textOutput("date_text")
  )
)

server.R

shinyServer(function(input, output) {

  observeEvent(input$clear_ui,{
    output$date_ui <- renderUI({NULL})
  })

  observeEvent(input$clear_date,{
    output$date <- NULL
  })

  output$date_ui <- renderUI({
    dateRangeInput("date", "a", start = "2001-01-01", end   = "2010-12-31")
  })

  output$date_text <- renderText({
    input$date
  })

})

global.R

library(shiny)
library(DBI)
library(pool)

pool <- dbPool(
  drv = RMySQL::MySQL(),
  dbname = "shinydemo",
  host = "shiny-demo.csa7qlmguqrf.us-east-1.rds.amazonaws.com",
  username = "guest",
  password = "guest"
)

By using "clear_ui", ui of daterangeInput can be deleted. However, the contents of the output "date" will remain. Is it possible to delete "date" data by using "clear_date"?

1

1 Answers

0
votes

You need to replace output$date by output$date_text in:

  observeEvent(input$clear_date,{
    output$date <- NULL
  })