0

I have a shiny app where I want to have an airDatePicker in a DT datatable. So far I'm able to get the airDatePicker showing up for each row of the table, but the language is all wrong. Using language = "en" as an argument doesn't work. I suspect the issue is related to how the widget's dependencies are being attached but I'm not sure where to start.

Here's a reprex:

library(DT)
library(purrr)
library(shiny)
library(shinyWidgets)

df <- data.frame(
  id = 1:10,
  time = map_chr(1:10, ~{
    airDatepickerInput(paste0("time_input_", .x), timepicker = TRUE, language = "en") |> 
      as.character() |> 
      HTML()
  })
)

# Define UI for application that draws a histogram
ui <- fluidPage(

  # To ensure dependencies are loaded
  div(style = "display: none;",
      airDatepickerInput("blank", label = NULL, language = "en", timepicker = TRUE)
  ),
  
  DTOutput("table")
)

# Define server logic required to draw a histogram
server <- function(input, output) {
  
  output$table <- renderDT({
    DT::datatable(df,
                  options = list(scrollX = FALSE,
                                 paging = FALSE,
                                 processing = FALSE,
                                 dom = 't',
                                 preDrawCallback = JS('function() { Shiny.unbindAll(this.api().table().node()); }'),
                                 drawCallback = JS('function() { Shiny.bindAll(this.api().table().node()); } ')),
                  escape = FALSE)
  })
    
}

# Run the application 
shinyApp(ui = ui, server = server)

Here's an image of the result when running the app and clicking on one of the airDatePicker input boxes:

enter image description here

Will Hipson
  • 366
  • 2
  • 9

0 Answers0