Skip to contents

Allow to edit content of columns with a calendar and time picker, then retrieve value server-side in shiny application with input$<outputId>_data.

Usage

grid_editor_date(
  grid,
  column,
  format = "yyyy-MM-dd",
  type = c("date", "month", "year"),
  timepicker = c("none", "tab", "normal")
)

Arguments

grid

A table created with datagrid().

column

Column for which to activate the date picker.

format

Date format, default is "yyyy-MM-dd".

type

Type of selection: date, month or year.

timepicker

Add a timepicker.

Value

A datagrid htmlwidget.

See also

grid_editor for normal inputs.

Examples

library(toastui)

dat <- data.frame(
  date = Sys.Date() + 1:10,
  month = format(Sys.Date() + 1:10, format = "%Y-%m"),
  year = format(Sys.Date() + 1:10, format = "%Y"),
  time1 = Sys.time() + 1:10,
  time2 = Sys.time() + 1:10
)


datagrid(dat) %>% 
  grid_editor_date(
    column = "date"
  ) %>% 
  grid_editor_date(
    column = "month",
    type = "month",
    format = "yyyy-MM"
  ) %>% 
  grid_editor_date(
    column = "year",
    type = "year",
    format = "yyyy"
  ) %>% 
  grid_editor_date(
    column = "time1", 
    timepicker = "tab",
    format = "yyyy-MM-dd HH:mm"
  ) %>% 
  grid_editor_date(
    column = "time2", 
    timepicker = "normal",
    format = "yyyy-MM-dd HH:mm"
  )