Skip to main content

print

Description

Fires when printing the table

Usage

"print": ({
mode?: "landscape"|"portrait",
paper?: "a3", "a4", "letter",
ppi?: number,
});

Parameters

The callback of the action takes an object with the following parameters:

  • mode - (optional) print mode that can be "landscape" or "portrait"
  • paper - (optional) paper size and format that can be "a3", "a4", "letter"
  • ppi - (optional) resolution in pixels of a table; 100 is set by default

Example

import { useRef } from "react";
import { Button } from "@svar-ui/react-core"; // import the Button component
import { Grid } from "@svar-ui/react-grid";
import { getData } from "../data";

export default function Example() {
const { data, columns } = getData();

const apiRef = useRef(null);

function printGrid() {
apiRef.current.exec("print");
}

return (
<>
<Button onClick={() => printGrid()} type="primary">Print Grid</Button>

<div style={{ height: 400, marginTop: 10 }}>
<Grid
ref={apiRef}
data={data}
columns={columns}
/>
</div>
</>
);
}

Related articles: