1 | initial version |
You can modify the width of the column filter in an R shiny datatable using the columnDefs
argument in the renderDT()
function. Here is an example code:
library(shiny)
library(DT)
ui <- fluidPage(
DTOutput("table")
)
server <- function(input, output) {
output$table <- renderDT({
datatable(iris,
filter = 'top',
options = list(
columnDefs = list(list(targets = "_all", width = "20%"))
))
})
}
shinyApp(ui, server)
In this code, we set columnDefs
to a list of one element which sets the width of all columns to 20%. You can modify this value to your desired width. The targets
argument specifies the target columns, "_all" selects all columns, but you can also specify individual column indexes or names.