gridcn2.0.0
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.

Name
Email
Score
Silent Tiger
user0@example.com
4
Quick Lion
user1@example.com
89
Swift Wolf
user2@example.com
80
Eager Lion
user3@example.com
51
Eager Tiger
user4@example.com
83
Silent Wolf
user5@example.com
15
Swift Lion
user6@example.com
62
Eager Lion
user7@example.com
42
Eager Eagle
user8@example.com
35
Bold Tiger
user9@example.com
52
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.

On this page