ExportPlugin
Export Plugin for tbw-grid
Lets users download grid data as CSV, Excel (XML), or JSON with a single click or API call. Great for reporting, data backup, or letting users work with data in Excel. Integrates with SelectionPlugin to export only selected rows.
Installation
Section titled “Installation”import { ExportPlugin } from '@toolbox-web/grid/plugins/export';Configuration Options
Section titled “Configuration Options”| Option | Type | Default | Description |
|---|---|---|---|
fileName | string | 'export' | Base filename (without extension) |
includeHeaders | boolean | true | Include column headers in export |
onlyVisible | boolean | true | Export only visible columns |
onlySelected | boolean | false | Export only selected rows (requires SelectionPlugin) |
Supported Formats
Section titled “Supported Formats”| Format | Method | Description |
|---|---|---|
| CSV | exportToCSV() | Comma-separated values |
| Excel | exportToExcel() | Excel XML format (.xlsx) |
| JSON | exportToJSON() | JSON array of objects |
Programmatic API
Section titled “Programmatic API”| Method | Signature | Description |
|---|---|---|
exportToCSV | (params?) => void | Export as CSV file |
exportToExcel | (params?) => void | Export as Excel file |
exportToJSON | (params?) => void | Export as JSON file |
isExporting | () => boolean | Check if export is in progress |
Examples
Section titled “Examples”Basic Export with Button
Section titled “Basic Export with Button”import { queryGrid } from '@toolbox-web/grid';import { ExportPlugin } from '@toolbox-web/grid/plugins/export';
const grid = queryGrid('tbw-grid');grid.gridConfig = { columns: [ { field: 'name', header: 'Name' }, { field: 'email', header: 'Email' }, ], plugins: [new ExportPlugin({ fileName: 'employees', includeHeaders: true })],};
// Trigger export via buttondocument.getElementById('export-btn').addEventListener('click', () => { grid.getPluginByName('export').exportToCSV();});Export Selected Rows Only
Section titled “Export Selected Rows Only”import { SelectionPlugin } from '@toolbox-web/grid/plugins/selection';
grid.gridConfig = { plugins: [ new SelectionPlugin({ mode: 'row' }), new ExportPlugin({ onlySelected: true }), ],};See Also
Section titled “See Also”ExportConfigfor all configuration optionsExportParamsfor method parametersSelectionPluginfor exporting selected rows
Extends BaseGridPlugin
Inherited methods like
attach(),detach(),afterRender(), etc. are documented in the base class.
Methods
Section titled “Methods”exportCsv()
Section titled “exportCsv()”Export data to CSV format.
exportCsv(params: Partial<ExportParams>): voidParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
params | Partial<ExportParams> | Optional export parameters |
exportExcel()
Section titled “exportExcel()”Export data to Excel format (XML Spreadsheet).
exportExcel(params: Partial<ExportParams>): voidParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
params | Partial<ExportParams> | Optional export parameters |
exportJson()
Section titled “exportJson()”Export data to JSON format.
exportJson(params: Partial<ExportParams>): voidParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
params | Partial<ExportParams> | Optional export parameters |
isExporting()
Section titled “isExporting()”Check if an export is currently in progress.
isExporting(): booleanReturns
Section titled “Returns”boolean - Whether export is in progress
getLastExport()
Section titled “getLastExport()”Get information about the last export.
getLastExport(): object | nullReturns
Section titled “Returns”object | null - Export info or null if no export has occurred
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