rshinydt

R datatable in DT the shiny filter "none" option doesn't work


I have just switched to using dataTables in my shiny app. In the ui, I have dataTableOutput("affordabilityTable") in a mainPanel and the following renderDataTable in the server

output$affordabilityTable <- renderDataTable({
    dt <- data.table::copy(data.afford())
    dt <- DT::datatable(dt, options = list(autoHideNavigation = TRUE, rownames = FALSE, filter = "none"))
#   dt <- DT::datatable(dt, options = list(dom = 't',ordering = F))
dt
})

The commented code works, in the sense that it turns off filtering, column sorting, etc. It does leave row numbers in the first column which I can't figure out how to get rid of. The uncommented datatable line leaves all the filter features showing.

The code I have included is not complete enough to reproduce the problem with row numbers but I'm hoping there is some fix that is obvious to someone with some datatable experience.


Solution

  • rownames parameter is part of datatable call, not inside the options. Or more specifically

    dt <- DT::datatable(dt, rownames = FALSE, options = list(dom = 't',ordering = F))
    

    I knew this is confusing. You can think that the options are the original js module datatable parameters, while there are some other parameters added by DT::datatable.