I am struggling to embed an autonumeric Input inside a DT table within a shiny app. I stumbled over this post here which made things a bit clearer for me.
However, I cant make it work for an autonumeric Input.
Here is what I have so far:
library(shiny)
library(DT)
library(shinyWidgets)
ui <-
tagList(
DTOutput("dtable")
)
server <- function(input, output){
output$dtable <-
renderDT(
{
dat <- data.frame(
select = c(
as.character(
autonumericInput(
inputId = 'id_1',
label = "Default Input 1",
value = 1.34
)
)
)
)
js <- c(
"function(settings){",
" $('[id^=id_1]').autoNumeric({",
" minimumValue: 1,",
" maximumValue: 2,",
" });",
"}"
)
datatable(
dat,
rownames = FALSE,
escape = FALSE,
options = list(
initComplete = JS(js),
preDrawCallback = JS('function() { Shiny.unbindAll(this.api().table().node()); }'),
drawCallback = JS('function() { Shiny.bindAll(this.api().table().node()); }')
)
)
}
)
}
shinyApp(ui, server)
I think the problem will probably be that the js-snippet is not correct and the initialization of the object does not work properly. However, I know close to nothing about JS and I am not sure on how to do this properly. Can anyone help me with this?