Skip to content

@jimka/typescript-ui / component/table / TableExporter

Class: TableExporter

Defined in: src/typescript/lib/component/table/TableExporter.ts:30

Stateless helper that converts a column list and a record list into a CSV or JSON download.

Remarks

Used internally by Table.exportCSV and Table.exportJSON. Date, time, and datetime values are formatted with the same toLocale* options the cell renderers use, so exports match what the user sees.

Constructors

new TableExporter()

ts
new TableExporter(): TableExporter

Returns

TableExporter

Methods

exportCSV()

ts
static exportCSV(
   columns: Column[], 
   records: ModelRecord[], 
   columnConfigs: Map<string, ColumnConfig>, 
   options?: ExportOptions): void

Defined in: src/typescript/lib/component/table/TableExporter.ts:40

Converts columns + records to an RFC 4180 CSV string and triggers a download.

Parameters

columns

Column[]

The columns to include as fields in the CSV.

records

ModelRecord[]

The records to serialize as rows.

columnConfigs

Map<string, ColumnConfig>

Per-field column config map (carries showSeconds for time/datetime).

options?

ExportOptions

Optional export options.

Returns

void


exportJSON()

ts
static exportJSON(
   columns: Column[], 
   records: ModelRecord[], 
   columnConfigs: Map<string, ColumnConfig>, 
   options?: ExportOptions): void

Defined in: src/typescript/lib/component/table/TableExporter.ts:69

Converts columns + records to a pretty-printed JSON array of objects and triggers a download.

Parameters

columns

Column[]

The columns whose field names become the keys of each emitted object.

records

ModelRecord[]

The records to serialize.

columnConfigs

Map<string, ColumnConfig>

Per-field column config map (carries showSeconds for time/datetime).

options?

ExportOptions

Optional export options.

Returns

void