Skip to content

useGridExport

Hook for programmatic export control.

Must be used within a DataGrid component tree with the export feature enabled.

useGridExport(selector: string): ExportMethods
NameTypeDescription
selectorstringOptional CSS selector to target a specific grid element via
DOM query instead of using React context. Use when the component contains
multiple grids, e.g. 'tbw-grid.primary' or '#my-grid'.
import { useGridExport } from '@toolbox-web/grid-react/features/export';
function ExportToolbar() {
const { exportToCsv, exportToExcel, exportToJson, isExporting } = useGridExport();
return (
<div>
<button onClick={() => exportToCsv()} disabled={isExporting()}>CSV</button>
<button onClick={() => exportToExcel()} disabled={isExporting()}>Excel</button>
<button onClick={() => exportToJson()} disabled={isExporting()}>JSON</button>
</div>
);
}
AI assistants: For complete API documentation, implementation guides, and code examples for this library, see https://raw.githubusercontent.com/OysteinAmundsen/toolbox/main/llms-full.txt