I have a datatable in my Shiny app. By default, the column names are the column names of the data set. I want to change the column names of the display, without touching the data set itself.
I found this documentation which is exactly what I need, but I'm not sure how to convert this to R syntax.
This is the current way I render the table:
output$score_data_table <- renderDataTable({
    selectedArea_overview_TC()}, 
    options = list(orderClasses = TRUE, 
                   lengthMenu = list(c(15,25,50,100,-1), c('15','25','50','100','All')),
                   pageLength = 15,
                   order=list(1, 'desc'))
)
I've tried adding the columnDefs option in several ways but nothing worked.
Any hint would be greatly appreciated!
You can use colnames in the renderDataTable. Something like:
  output$table1 <- DT::renderDataTable({
     datatable(messages(),
     colnames = c('Type', 'Message', 'Check', 'Entity',   'ID','File'), 
     options = list(pageLength = 50, autoWidth = TRUE,
     columnDefs = list(list(width = '800px', targets = c(2)))),filter='top')})  
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With