cal_proxy_view: Change calendar view with Proxy

Description Usage Arguments Examples

View source: R/proxy.R

Description

This function allow to change the calendar view from the server in a Shiny application.

Usage

1
cal_proxy_view(proxy, view)

Arguments

proxy

A calendarProxy htmlwidget object.

view

The new view for the calendar: "day", "week" or "month".

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
if (interactive()) {
  library(shiny)
  
  ui <- fluidPage(
    tags$h2("Navigate in calendar with actionButtons"),
    radioButtons(
      inputId = "view", 
      label = "Change view:", 
      choices = c("day", "week", "month"), 
      inline = TRUE
    ),
    calendarOutput(outputId = "my_calendar")
  )
  
  server <- function(input, output, session) {
    
    output$my_calendar <- renderCalendar({
      calendar(defaultView = "day", scheduleView = "allday") %>% 
        add_schedule(
          title = "Today planning", 
          start = Sys.Date(),
          end = Sys.Date(),
          category = "allday"
        )
    })
    
    observeEvent(
      input$view, 
      cal_proxy_view("my_calendar", input$view), 
      ignoreInit = TRUE
    )
    
  }
  
  shinyApp(ui, server)
}

dreamRs/tuicalendr documentation built on Aug. 4, 2021, 12:02 a.m.