0
votes

I would like to hide the column filters in Shiny DT datatable but I cannot: enter image description here

here is my approach:

library(shiny)
library(DT)

ui <- fluidPage(
  tags$style("#mydatatable thead > tr:nth-child(2) {display:none;}"),
  mainPanel(
    dataTableOutput("mydatatable")
  )
)

server <- function(input, output) {

  output$mydatatable <- DT::renderDataTable(
    datatable(iris, filter = 'top', options = list(
      pageLength = 5, autoWidth = TRUE)
    )
  )

}

shinyApp(ui = ui, server = server)
1
Use datatable(iris, filter = "none", ...) insteadGabriel Silva
that worked thanksfirmo23
@GabrielSilva make it an answer, it will help crawlers index it and will help people find a good answer.Fausto Carvalho Marques Silva
@FaustoCarvalhoMarquesSilva DoneGabriel Silva

1 Answers

2
votes

You can hide/delete filters by especifying the filter = "none" argument of the DT::datatable function or as an additional argument of the DT::renderDataTable function.

Options for filter are any of c("top", "bottom", "none")

output$mydatatable <- DT::renderDataTable({
    datatable(iris, filter = "none")
  })

renderDataTable converts a data object (e.g. a dataframe) to a datatable. Additional datatable arguments (...) are passed after the expr argument. For a list of the possible arguments and options, check the documentation ?DT::datatable.

output$mydatatable <- DT::renderDataTable({
    iris
  },
  filter = "none"
)