Core Features

Advanced Features

React Data GridPDF Export - Columns

Version 36.2.0
Enterprise

PDF Export includes the currently displayed columns in their displayed order by default. Export parameters can include hidden columns, choose a specific column set, suppress headers, or include the Row Numbers column.

Column Headers Copy Link

Column headers and column-group headers are exported by default. Set skipColumnHeaders=true or skipColumnGroupHeaders=true to omit the corresponding header rows.

gridApi.exportDataAsPdf({
    skipColumnHeaders: false,
    skipColumnGroupHeaders: true,
});

When headers are included, processHeaderCallback and processGroupHeaderCallback can customise their exported text.

Hidden And Specific Columns Copy Link

Hidden columns are omitted by default. Set allColumns=true to export every primary column in columnDefs order, including hidden columns.

gridApi.exportDataAsPdf({
    allColumns: true,
});

Use columnKeys when only a specific set of columns should be exported. The supplied column keys or Column objects also determine their export order.

gridApi.exportDataAsPdf({
    columnKeys: ['customer', 'product', 'total'],
});

When pivot mode is active, PDF Export uses the currently displayed pivot result columns. Hidden or collapsed pivot result columns are not added by allColumns.

Column Groups Copy Link

Displayed column-group headers are rendered as PDF header rows. A PDF cannot contain interactive collapsible column groups, so exported groups are a static representation of the selected columns.

Columns hidden by a closed grid group are omitted by default. Use allColumns=true to include every primary column, or use columnKeys for precise control over the exported column set.

Row Numbers Copy Link

The Row Numbers column is not exported by default, even when it is displayed in the grid. Set exportRowNumbers=true to include it.

gridApi.exportDataAsPdf({
    exportRowNumbers: true,
});

When columnWidth is omitted, the exported Row Numbers column is sized automatically from its contents. A global or per-column columnWidth configuration can override this behaviour.

The example below demonstrates header suppression, visible or hidden column selection, and Row Numbers export.

Column Widths Copy Link

The columnWidth option accepts:

  • 'grid' to use the current column width in the grid.
  • 'auto' to size each column to fit its contents.
  • A number to use a fixed width in points.
  • A callback to return a custom value for each column.

When columnWidth is omitted, regular columns use 'grid' and the Row Numbers column uses 'auto'. A columnWidth value overrides those defaults; a callback result overrides the default for that column. Returning null or undefined from the callback uses the column's default mode.

Auto widths are measured before page scaling. If the combined widths exceed the printable page width, every column is reduced proportionally. Smaller tables are not stretched. Horizontal pagination and automatically expanding the page size are not supported.

PDF layout dimensions use points, where 72 points equal one inch.

API Copy Link

Export Options Copy Link

columnWidthCopy Link
PdfColumnWidth | PdfColumnWidthCallback
default: 'grid'
Controls exported column widths. Use auto to size from exported content, grid to use the current column width in the grid, a number for a width in points, or a callback for per-column control. Widths are proportionally reduced when their total exceeds the printable page width.
exportRowNumbersCopy Link
boolean
default: false
Set to true to allow the contents of the Row Numbers column to be exported.
allColumnsCopy Link
boolean
default: false
If true, all columns will be exported in the order they appear in the columnDefs. When false only the columns currently being displayed will be exported.
columnKeysCopy Link
(string | Column)[]
Provide a list (an array) of column keys or Column objects if you want to export specific columns.
skipColumnGroupHeadersCopy Link
boolean
default: false
Set to true to exclude header column groups.
skipColumnHeadersCopy Link
boolean
default: false
Set to true if you don't want to export column headers.

ColumnWidthCallbackParams Copy Link

Properties available on the ColumnWidthCallbackParams interface.

Column | null
number
number