Home > Net >  Hide the sorting arrows of the column names in DT::datatable
Hide the sorting arrows of the column names in DT::datatable

Time:01-31

How can we hide the sorting arrows that are next to the column names in DT::datatable()?

    ## app.R ##
    library(shiny)
    library(shinydashboard)
    
    ui <- dashboardPage(
      dashboardHeader(),
      dashboardSidebar(),
      dashboardBody(
datatableOutput("table"))
    )
    
    server <- function(input, output) { }
    output$table<-renderDataTable({ 
datatable("iris")
})

    shinyApp(ui, server)

CodePudding user response:

options = list(ordering = FALSE)

in the datatable function.

This turns off the sorting for all columns.

If you want to disable for some columns only, say column 2:

options = list(
  columnDefs = list(
    list(targets = 2, orderable = FALSE)
  )
)
  • Related