Buttons (DataTables Setting)
The Buttons setting puts a row of buttons above a DataTables View, so visitors can copy, download or print the entries in the table.

Choose the buttons #
- Edit your View.
- In the Settings box, click the DataTables tab.
- Under Buttons, make sure Enable Buttons is on, then turn on each button you want.
- Click Update.

A new View has Copy, CSV and Print turned on. Excel, PDF and Column Visibility stay off until you turn them on.
The buttons on the page #
| Button | What it does |
|---|---|
| Copy | Copies the entries to the clipboard and shows how many rows it copied. |
| CSV | Downloads a CSV file named after the page’s title as the browser tab shows it. |
| Excel | Downloads an Excel file with the same name, with the title in its first row. |
| Makes a PDF on wide A3 pages, with the same title at the top. | |
| Shows the table in a new window and opens your browser’s print dialog. | |
| Columns | Lists the table’s columns, so visitors can hide or show each one. The button is called Column Visibility in the settings. |
Entries and columns in the files #
The buttons build each file in the visitor’s browser from the table on the page. A file holds every entry that matches the table’s search box and Field Filters, in the order the table is sorted, including entries on other pages of the table.
Columns a visitor hides with Columns stay out of the files. On a narrow screen, the columns that the Responsive setting folds into a row’s details are still in the files.
Each cell holds the text the table shows. Some links add their address in parentheses after their text, and Showing URLs in DataTables Excel exports lists which ones.
To print images, see Showing images and URLs in DataTables printouts. For PDF files, see Adding a company logo to DataTables PDF exports, Showing images in DataTables PDF exports and Making links clickable in DataTables PDF exports.
Because the files copy the table, code that changes what a field shows, such as the gravityview/template/field/output filter, changes the files too. A column can stay in the table and still be left out of the files, as the next section shows.
In the Ajax (Server-side) processing mode, a button handles up to 1,000 entries. When more entries match, the table shows “There are too many rows to export at once. Refine your search and try again.” and no file is made.
To export more, a visitor can pick All in the Show entries menu first. The table then loads every entry, and the buttons save them all. The Preloaded (Client-side) mode has no such limit.
Developers can change the limit with the gk/gravityview/datatables/export/max-rows filter, or turn it off by returning 0.
Leaving a column out of the files #
With Column Visibility turned on, visitors pick the columns themselves. To keep a column on the page and out of every file, such as an Edit Entry link, give it a CSS class and tell the buttons to skip that class:
- Edit your View. Under Visible Table Columns, click the gear icon on the column’s field.
- Under Advanced, type
no-exportin Custom CSS Class, then click Close and Update.

Then add this code to your site:
/**
* Leaves the columns with the CSS class "no-export" out of the files
* that the Copy, CSV, Excel, PDF and Print buttons make.
*
* @param array $button_config The button's settings.
* @param string $button The button: copy, csv, excel, pdf, print or colvis.
* @param int $view_id The ID of the View.
*
* @return array The changed settings.
*/
add_filter( 'gravityview/datatables/button', function ( $button_config, $button, $view_id ) {
// The Columns button makes no file.
if ( 'colvis' === $button ) {
return $button_config;
}
// ":visible" keeps the columns hidden in the table out of the files too.
$button_config['exportOptions']['columns'] = ':visible:not(.no-export)';
return $button_config;
}, 10, 3 );Note: Adding custom PHP code snippets to your website shows where to put this code. The developer reference for this filter lists its parameters.
The column stays in the table, and the files hold the other columns the table shows.
Keep :visible in the code. It leaves out the columns hidden in the table, such as the ones a visitor hides with Columns. Without it, those columns come back into the files.
With the Responsive setting on, :visible also leaves out the columns that Responsive folds away on a narrow screen, which the files hold without this code. A file exported from a phone then holds only the columns the phone shows.
Buttons and the Permissions tab #
These buttons work apart from the Allow Export and Show All In File settings on the Permissions tab. Those two settings control the View’s CSV and TSV download link, which Exporting entries as CSV or TSV from GravityView explains.