简体   繁体   中英

Make shiny's `dateRangeInput`'s `end` always bigger than `start`

I'm making a shiny app with dateRangeInput . I want to make the date selection in such a way, that the user cannot select smaller date in second date input than first date input.
示例图片
For example from the above image, shiny now let's user select dates from 2017 in second date input after having selected July 26,2018 in first date input. I now want to make changes such that second date input always starts a day after first date input, like user can't select or even see July 26,2018 in second input and always sees a day after that like July 27,2018, after selecting July 26,2018 in first date input. I've check documentation for dateRangeInput , nothing such was available there.
So, how do i do this?

An alternative to prevent user from selecting start > end can be found in shinyWidgets:

library(shiny)

ui <- fluidPage(
  shinyWidgets::airDatepickerInput("daterange", "Date range:",
                                   range = TRUE,
                                   value = c("2010-01-01", "2001-12-31")),
  verbatimTextOutput("res")
)
server <- function(input, output, session) {
  output$res <- renderPrint({
    paste("Start at", input$daterange[1], "and end at", input$daterange[2])
  })
}
shinyApp(ui, server)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM