jQuery/JS Common - Object Structures - PdfExportDataGridProps
Properties that can be passed as a parameter to the exportDataGrid(options) method from the pdfExporter module.
The exportDataGrid(options) method requires the jsPDF v2.3.1+ library to export data and create PDF files.
- $(function(){
- $('#exportButton').dxButton({
- // ...
- onClick: function() {
- const doc = new jsPDF();
- DevExpress.pdfExporter.exportDataGrid({
- jsPDFDocument: doc,
- component: dataGrid
- }).then(function() {
- doc.save('Customers.pdf');
- });
- }
- });
- const dataGrid = $('#gridContainer').dxDataGrid({
- // ...
- }).dxDataGrid('instance');
- });
- <head>
- <!-- ... -->
- <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.0.0/jspdf.umd.min.js"></script>
- <!-- DevExtreme sources are referenced here -->
- </head>
columnWidths
Specifies a custom width for the exported DataGrid columns.
Uses the measure units that are specified in the constructor of the jsPDFDocument object.
The example below calls the exportDataGrid(options) method on a button click. This method applies specific widths to the grid columns.
- $(function(){
- $('#exportButton').dxButton({
- // ...
- onClick: function() {
- const doc = new jsPDF();
- DevExpress.pdfExporter.exportDataGrid({
- jsPDFDocument: doc,
- component: dataGrid,
- columnWidths: [50, 40, 40, 40]
- }).then(function() {
- doc.save('Customers.pdf');
- });
- }
- });
- const dataGrid = $('#gridContainer').dxDataGrid({
- // ...
- }).dxDataGrid('instance');
- });
- <head>
- <!-- ... -->
- <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.0.0/jspdf.umd.min.js"></script>
- <!-- DevExtreme sources are referenced here -->
- </head>
customDrawCell
A function that allows you to draw cell content of the exported DataGrid. This function is executed before the cell is exported.
Information about the event.
| Name | Type | Description |
|---|---|---|
| cancel | Allows you to prevent default drawing logic. | |
| doc | An instance of the jsPDFDocument object. | |
| gridCell | A DataGrid cell. | |
| pdfCell | An object that describes a cell in a PDF file. | |
| rect | An object that contains information about the location of the cell and its dimensions. The object has the following structure: { x: numeric, y: numeric, h: numeric, w: numeric }. |
Allows you to prevent default drawing logic.
An instance of the jsPDFDocument object.
A DataGrid cell.
An object that describes a cell in a PDF file.
An object that contains information about the location of the cell and its dimensions. The object has the following structure: { x: numeric, y: numeric, h: numeric, w: numeric }.
In the following example, this function adds an image to a cell:
- $(function(){
- $('#exportButton').dxButton({
- // ...
- onClick: function() {
- const doc = new jsPDF();
- DevExpress.pdfExporter.exportDataGrid({
- jsPDFDocument: doc,
- component: dataGrid,
- customDrawCell: (e) => {
- if (e.gridCell.rowType === 'data' && e.gridCell.column.dataField === 'Picture') {
- doc.addImage(e.gridCell.value, 'PNG', e.rect.x, e.rect.y, e.rect.w, e.rect.h);
- e.cancel = true;
- }
- },
- }).then(function() {
- doc.save('Customers.pdf');
- });
- }
- });
- const dataGrid = $('#gridContainer').dxDataGrid({
- // ...
- }).dxDataGrid('instance');
- });
customizeCell
Customizes a cell in PDF after creation.
An object passed to this callback function.
| Name | Type | Description |
|---|---|---|
| gridCell | A DataGrid cell. | |
| pdfCell | An object that describes a cell in a PDF file. |
A DataGrid cell.
An object that describes a cell in a PDF file.
In the following example, this function changes the font size of the 'data' group row cells:
- $(function(){
- $('#exportButton').dxButton({
- // ...
- onClick: function() {
- const doc = new jsPDF();
- DevExpress.pdfExporter.exportDataGrid({
- jsPDFDocument: doc,
- component: dataGrid,
- customizeCell: function(options) {
- const { gridCell, pdfCell } = options;
- if(gridCell.rowType === 'data') {
- pdfCell.font = { size: 20 };
- }
- }
- }).then(function() {
- doc.save('Customers.pdf');
- });
- }
- });
- const dataGrid = $('#gridContainer').dxDataGrid({
- // ...
- }).dxDataGrid('instance');
- });
See Also
- pdfExporter.exportDataGrid(options)
indent
Specifies the width of the indent of data rows relative to their group header row.
This property uses the measure units that are specified in the constructor of the jsPDFDocument object.

- $(function(){
- $('#exportButton').dxButton({
- // ...
- onClick: function() {
- const doc = new jsPDF();
- DevExpress.pdfExporter.exportDataGrid({
- jsPDFDocument: doc,
- component: dataGrid,
- indent: 15
- }).then(function() {
- doc.save('Customers.pdf');
- });
- }
- });
- const dataGrid = $('#gridContainer').dxDataGrid({
- // ...
- }).dxDataGrid('instance');
- });
- <head>
- <!-- ... -->
- <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.0.0/jspdf.umd.min.js"></script>
- <!-- DevExtreme sources are referenced here -->
- </head>
jsPDFDocument
A jsPDF instance. This setting is required.
loadPanel
Configures the load panel.
The example below calls the exportDataGrid(options) method on a button click. This method enables the load panel and applies shading to the grid.
- $(function(){
- $('#exportButton').dxButton({
- // ...
- onClick: function() {
- const doc = new jsPDF();
- DevExpress.pdfExporter.exportDataGrid({
- jsPDFDocument: doc,
- component: dataGrid,
- loadPanel: {
- enabled: true,
- shading: true,
- shadingColor: "#808080"
- }
- }).then(function() {
- doc.save('Customers.pdf');
- });
- }
- });
- const dataGrid = $('#gridContainer').dxDataGrid({
- // ...
- }).dxDataGrid('instance');
- });
- <head>
- <!-- ... -->
- <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.0.0/jspdf.umd.min.js"></script>
- <!-- DevExtreme sources are referenced here -->
- </head>
margin
Specifies the margin for the top, bottom, left, and right sides of the exported Grid.
Uses the measure units that are specified in the constructor of the jsPDFDocument object.
- $(function(){
- $('#exportButton').dxButton({
- // ...
- onClick: function() {
- const doc = new jsPDF();
- DevExpress.pdfExporter.exportDataGrid({
- margin: { top: 20, right: 20, bottom: 20, left: 20 },
- jsPDFDocument: doc,
- component: dataGrid,
- }).then(function() {
- doc.save('Customers.pdf');
- });
- }
- });
- const dataGrid = $('#gridContainer').dxDataGrid({
- // ...
- }).dxDataGrid('instance');
- });
See Also
- pdfExporter.exportDataGrid(options)
onRowExporting
A function that allows you to customize the height of the exported row. This function is executed before the row export.
Information about the event.
| Name | Type | Description |
|---|---|---|
| rowCells | An array of cells of the exported row. | |
| rowHeight | Specifies the height of the exported row. If the specified value is less than the height of the text, the component increases the row height automatically. |
- $(function(){
- $('#exportButton').dxButton({
- // ...
- onClick: function() {
- const doc = new jsPDF();
- DevExpress.pdfExporter.exportDataGrid({
- jsPDFDocument: doc,
- component: dataGrid,
- onRowExporting: (e) => {
- e.rowHeight = 20;
- },
- }).then(function() {
- doc.save('Customers.pdf');
- });
- }
- });
- const dataGrid = $('#gridContainer').dxDataGrid({
- // ...
- }).dxDataGrid('instance');
- });
repeatHeaders
Specifies whether to repeat the DataGrid column headers on each page.