Please use Github issues to file bug reports or feature requests, and use StackOverflow to ask questions.
ExportOptions - columns — DataTables forums
This page is a quick access reference for initialisation options and API methods. To view The details of each option, including a code sample, simply click on the row.
DataTables example - Export options - column selector
This table loads data by Ajax. The latest data that has been loaded is shown below. This data will update automatically as any additional data is loaded.
This can be cumbersome if you only want to replace one or two names, and you do not want to provide a whole vector of names. Then here is the second possibility: you can provide a shorter numeric or character vector as the index vector to replace a subset of the column names. For example, if you only want the 7nd name to be 'A Nicer Name' , you can use datatable(., colnames = c('A Nicer Name' = 7)) or if you want to replace the name 'X5' with 'A Better Name' , you can use colnames = c('A Better Name' = 'X5').
The column visibility buttons ( colvis ) are included in this example so the column visibility can be easily changed. Additionally, the last column in the table, Salary, is hidden by default (using ).
You can enable table editing using the argument editable (see ?DT::datatable for its possible values). Then you will be able to double-click a cell to edit its value. It works in both client-side and server-side processing modes. Below are two client-side examples (also see a Shiny example with server-side processing):
In order to include only visible columns except for the last column, so that you can use this in conjunction with the Column Visibility Button, use
You may install the stable version from CRAN, or the development version using remotes::install_github('rstudio/DT') if necessary (this website reflects the development version of DT ):
This example uses a little bit of additional CSS beyond what is loaded from the library files (below), in order to correctly display the table. The additional CSS used is shown below:
I try to set in the exportOption the column Number that are shown by the login level.
I tried it with this code:
I just thought I'd add this in because the accepted answer only works to exclude if you are not already including something else (such as visible columns).