Ask Your Question
4

How can I modify the width of the column filter in an R shiny datatable?

asked 2022-10-05 11:00:00 +0000

huitzilopochtli gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-05-27 03:00:00 +0000

lakamha gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-10-05 11:00:00 +0000

Seen: 17 times

Last updated: May 27 '21