-
Data Grids / Data Management
-
Data Grid
- Overview
-
Data Binding
-
Filtering
- Sorting
-
Editing
-
Grouping
-
Selection
- Focused Row
- Paging
-
Scrolling
-
Columns
-
Master-Detail
-
Data Summaries
-
Drag & Drop
-
Export to PDF
-
Export to Excel
- Appearance
-
Customization
- State Persistence
-
Adaptability
-
Keyboard Navigation
- Right-To-Left Support
-
Tree List
- Overview
-
Data Binding
-
Filtering
- Sorting
-
Editing
-
Selection
- Focused Row
- Paging
-
Columns
- Drag & Drop
- State Persistence
- Adaptability
-
Keyboard Navigation
-
Card View
-
Pivot Grid
- Overview
-
Data Binding
-
Field Management
-
Data Summaries
- Drill Down
- Filtering
-
Scrolling
-
Export to Excel
- Chart Integration
- Customization
- State Persistence
-
Filter Builder
-
-
Data Visualization
-
Charts
- Overview
-
Data Binding
-
Common Concepts
-
Axis
-
Aggregation
-
Tooltips
-
Selection
-
Customization
-
Zooming
-
Export
-
-
Area Charts
-
Bar Charts
- Bullet Charts
-
Doughnut Charts
-
Financial Charts
-
Funnel and Pyramid Charts
-
Line Charts
- Pareto Chart
-
Pie Charts
-
Point Charts
-
Polar and Radar Charts
-
Range Charts
- Sankey Chart
-
Sparkline Charts
-
Tree Map
-
Gauges
- Overview
-
Runtime update
-
Bar Gauge
-
Circular Gauge
-
Linear Gauge
-
Diagram
- Overview
-
Data Binding
-
Featured Shapes
-
Custom Shapes
-
Document Capabilities
-
User Interaction
- UI Customization
- Adaptability
-
-
Scheduling / Planning
-
Scheduler
- Overview
-
Data Binding
-
Views
-
Appointments
-
Timetable
- Editing
-
Grouping
- Virtual Scrolling
- Drag & Drop
-
Customization
- Adaptability
-
Gantt
- Overview
- Data Binding
-
Filtering
- Sorting
- Strip Lines
- Export to PDF
- Validation
-
Customization
-
-
Messaging
-
WYSIWYG Editor
-
Forms
-
Data Editors
- Overview
-
Common Concepts
-
Calendar
- Check Box
- Color Box
- Date Box
-
Date Range Box
-
Number Box
- Radio Group
-
Range Selector
- Range Slider
- Slider
- Switch
- Text Area
- Text Box
-
Drop-Downs
- Autocomplete
-
Drop Down Box
-
Select Box
-
Tag Box
-
Lookup
-
Buttons
-
File Upload / File Management
-
File Manager
- Overview
-
File System Types
-
Customization
-
File Uploader
-
-
Popup and Notifications
-
Navigation
- Overview
- Accordion
-
Context Menu
-
Menu
- Multi View
-
Drawer
-
Tab Panel
-
Tabs
-
Toolbar
-
Stepper
- Pagination
-
List
-
Tree View
- Right-to-Left Support
-
Layout
-
Tile View
- Splitter
-
Gallery
- Scroll View
-
-
Interactive Wrappers
-
Sortable
- Resizable
-
-
Progress Indicators
-
Maps
- Overview
-
Map
-
Vector Map
-
Data Binding
- Multiple Layers
-
Markers
- Legend
-
Zooming and Panning
-
Customization
-
-
Localization
Related Demos:
Your search did not match any results.
Data Grid - Multiple Grids Export
This demo shows two DataGrids in different tabs. Click the Export multiple grids button to export two grids and arrange them on different pages of the PDF document.
To implement this functionality, call the exportDataGrid(options) methods in a chain of Promises, one after another. Use the jsPDF.addPage() method to add a page in the PDF document.
You can use the customizeCell function to customize cell appearance in the PDF document. In this demo, the customizeCell function highlights alternate (even) rows.
Was this demo helpful?
Feel free to share demo-related thoughts here.
If you have technical questions, please create a support ticket in the DevExpress Support Center.
Thank you for the feedback!
If you have technical questions, please create a support ticket in the DevExpress Support Center.
Backend API
@section ExternalDependencies {
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
<script>
window.jsPDF = window.jspdf.jsPDF;
</script>
}
<div id="exportContainer">
@(Html.DevExtreme().Button()
.Text("Export multiple grids")
.Icon("exportpdf")
.OnClick("exportGrids"))
</div>
@(Html.DevExtreme().TabPanel()
.ID("tabPanel")
.DataSource(new[] {
new { text = "Price" },
new { text = "Rating" }
})
.ItemTemplate(new JS("tabPanelTemplate"))
.ItemTitleTemplate(@<text><span class="dx-tab-text"><%- text %></span></text>)
.DeferRendering(false))
<script>
var priceCaption = "Price";
var ratingCaption = "Rating";
function tabPanelTemplate(itemData, itemIndex, itemElement) {
if (itemData.text === priceCaption) {
var $gridContainer = $("<div id='priceDataGrid'>");
itemElement.append($gridContainer);
$gridContainer.dxDataGrid({
width: "100%",
columns: [
{ dataField: "Product_ID", caption: "ID", width: 50 },
{ dataField: "Product_Name", caption: "Name" },
{ dataField: "Product_Sale_Price", caption: "Sale Price", dataType: "number", format: "currency" },
{ dataField: "Product_Retail_Price", caption: "Retail Price", dataType: "number", format: "currency" }
],
showBorders: true,
rowAlternationEnabled: true,
dataSource: {
store: {
type: "odata",
version: 2,
url: "https://js.devexpress.com/Demos/DevAV/odata/Products",
key: "Product_ID"
},
select: ["Product_ID", "Product_Name", "Product_Sale_Price", "Product_Retail_Price"],
filter: ["Product_ID", "<", 10]
}
});
}
if (itemData.text === ratingCaption) {
var $gridContainer = $("<div id='ratingDataGrid'>");
itemElement.append($gridContainer);
$gridContainer.dxDataGrid({
width: "100%",
columns: [
{ dataField: "Product_ID", caption: "ID", width: 50 },
{ dataField: "Product_Name", caption: "Name" },
{ dataField: "Product_Consumer_Rating", caption: "Rating" },
{ dataField: "Product_Category", caption: "Category" }
],
showBorders: true,
rowAlternationEnabled: true,
dataSource: {
store: {
type: "odata",
version: 2,
url: "https://js.devexpress.com/Demos/DevAV/odata/Products",
key: 'Product_ID',
},
select: ["Product_ID", "Product_Name", "Product_Consumer_Rating", "Product_Category"],
filter: ["Product_ID", "<", 10]
}
});
}
}
function setAlternatingRowsBackground(dataGrid, gridCell, pdfCell) {
if (gridCell.rowType === 'data') {
const rowIndex = dataGrid.getRowIndexByKey(gridCell.data.Product_ID);
if (rowIndex % 2 === 0) {
pdfCell.backgroundColor = '#D3D3D3';
}
}
}
function exportGrids() {
const doc = new jsPDF();
const priceDataGrid = $("#priceDataGrid").dxDataGrid("instance");
DevExpress.pdfExporter.exportDataGrid({
jsPDFDocument: doc,
component: priceDataGrid,
topLeft: { x: 7, y: 5 },
columnWidths: [20, 50, 50, 50],
customizeCell: ({ gridCell, pdfCell }) => {
setAlternatingRowsBackground(priceDataGrid, gridCell, pdfCell);
},
}).then(() => {
doc.addPage();
const ratingDataGrid = $("#ratingDataGrid").dxDataGrid("instance");
DevExpress.pdfExporter.exportDataGrid({
jsPDFDocument: doc,
component: ratingDataGrid,
topLeft: { x: 7, y: 5 },
columnWidths: [20, 50, 50, 50],
customizeCell: ({ gridCell, pdfCell }) => {
setAlternatingRowsBackground(ratingDataGrid, gridCell, pdfCell);
},
}).then(() => {
doc.save('MultipleGrids.pdf');
});
});
}
</script>
using DevExtreme.MVC.Demos.Models;
using DevExtreme.MVC.Demos.Models.DataGrid;
using DevExtreme.MVC.Demos.Models.SampleData;
using System;
using System.Linq;
using System.Web.Mvc;
namespace DevExtreme.MVC.Demos.Controllers {
public class DataGridController : Controller {
public ActionResult PDFExportMultipleGrids() {
return View();
}
}
}
#priceDataGrid, #ratingDataGrid {
padding: 10px;
}
#exportContainer {
text-align: right;
}
#tabPanel {
padding-top: 10px;
}