Is there a way to prevent the table from resizing itself after refreshing data via the drop down menu?
I know this is exactly the same question as in R shiny - DT::renderDataTable column width but as far as I know the question was never sufficiently answered.
library(shiny)
library(tidyr)
library(dplyr)
library(DT)
ui <- fluidPage(selectInput(inputId = "dayinput",
label = "Day Filter",
choices = c("Monday", "Tuesday","Wednesday")),
dataTableOutput("table1")
)
server <- function(input, output) {
output$table1 <- renderDataTable({
price <- c("12", "11", "14")
day <- c("Monday", "Tuesday", "Wednesday")
df <- data.frame(price, day) %>% filter(day == input$dayinput)
datatable(df, rownames = FALSE, class = 'cell-border stripe',
options = list(dom = 't', pageLength = -1, lengthMenu = list(c(-1), c('All')),
autoWidth = TRUE, columnDefs = list(list(width = '50px', targets = "_all"))))
})
}
shinyApp(ui =ui, server = server)