useHeaders

DataTable
stable

Injects the DataTable header context created by createHeaders. Exposes the parsed multi-row header matrix, the flat column list, and the sort/filter function maps derived from the column definitions.

API

Signature

Full TypeScript signature sourced from the composable file.

typescript

useHeaders throws if called outside a component that has createHeaders in its ancestor chain. It relies on Vue provide/inject with ORIGAM_DATA_TABLE_HEADERS_KEY.

Consumed interfaces

IDataTableHeaderProps
IDataTableHeader
IInternalDataTableHeader

API

Parameters

Input parameters accepted by this composable.

props
required
IDataTableHeaderProps
createHeaders only — DataTable props including headers definition and items (used to auto-generate columns when headers is omitted).
options.groupBy
Ref<IDataTableSortItem[]>
createHeaders only — when set, prepends a data-table-group column to support row grouping.
options.showSelect
Ref<boolean>
createHeaders only — when true, prepends a data-table-select column for row checkboxes.
options.showExpand
Ref<boolean>
createHeaders only — when true, appends a data-table-expand column for row expansion toggles.

API

Return values

Properties and methods exposed by the composable return object.

headers
A 2D array representing the header rows. Multi-level headers produce multiple rows; simple tables produce a single row.
columns
Flat list of leaf columns (those that represent actual data cells). Used to drive the tbody cell rendering.
sortFunctions
Per-column custom sort comparators extracted from the header definitions.
sortRawFunctions
Per-column raw sort comparators (operating on unformatted values) extracted from the header definitions.
filterFunctions
Per-column filter functions extracted from the header definitions, keyed by column key.

Usage

Examples

Ready-to-paste usage snippets.

Creating headers in a DataTable parent

ts

Consuming headers in a child component

vue