Basic examples
Print example
Print the current view as a paged table, and pick the PDF paper size for the print dialog.
DataGridPrintButton opens the browser print dialog with a plain table of the current view. In the demo, the Page size select passes paperSize to the button. To check the size, choose "Save as PDF" in the dialog.
Print opens the browser print dialog with the current view, and the dialog uses the picked page size. Choose "Save as PDF" as the destination to check the page size.
pnpm dlx shadcn@latest add @gridcn/data-grid-print-demo
The button passes its options prop to printGrid:
import { DataGridPrintButton } from "@/components/data-grid-io/data-grid-io";
export function PrintLetterButton() {
return (
<DataGridPrintButton options={{ paperSize: "Letter", title: "Orders" }} />
);
}Place the button inside DataGridProvider, for example in DataGridToolbar. paperSize is "A4" (default), "A3", "Letter", or "Legal". title prints as a heading and sets the document title.
What the demo shows
- The printed table follows the view: the current sort, filters, and visible column order.
- The page is landscape when the grid shows more than 6 columns, and portrait otherwise.
- The table prints at most 10,000 rows by default.
Related
- Export: the print rules, the row limits, and server mode
- Export options: every
printGridoption