I'm trying to create a DT with several inputs in Shiny. The columns with selectInput and numericInput work fine, but the one with dateInputs doesn't. It's like the input$date_n does not exist at all.
I know close to nothing about JS, and I think the problem is probbaly in the drawCallback. I just copied this piece of code from another question in here, and it was working fine until I tried to use a dateInput.
Below, there's a small code reproducing the problem. The first two outputs are OK, but the third just doesnst show up.
library(shiny)
library(DT)
ui = fluidPage(title = 'Test',
DTOutput('table'),
verbatimTextOutput('chosen_letter'),
verbatimTextOutput('chosen_value'),
verbatimTextOutput('chosen_date'))
server <- shinyServer(function(input, output, session) {
output$table = renderDT({
sel_letter = paste0("<select id='letter_", 1:3, "'>
<option value='a' selected='selected'>A</option>
<option value='b'>B</option>
<option value='c'>C</option>
</select>")
sel_value = paste0("<input id='value_", 1:3, "' class='shiny-bound-input'
value = '", 1:3, "' type='number' step = '1'>")
sel_date = paste0("<input id='date_", 1:3, "' type='date' value='2018-07-31'
class='shiny-bound-input' min='2018-07-31' max='2018-12-31'>")
datatable(data.frame(Letter = sel_letter, Value = sel_value, Date = sel_date),
rownames = F, selection = 'none', escape = F,
options = list(drawCallback = JS('function(settings) {
Shiny.bindAll(this.api().table().node());}'),
dom = 't', ordering = F, pageLength = 15))
})
output$chosen_letter = renderText({c(input$letter_1, input$letter_2, input$letter_3)})
output$chosen_value = renderText({sum(input$value_1, input$value_2, input$value_3)})
output$chosen_date = renderText({input$date_1})
})
shinyApp(ui, server)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…