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.
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.
- propsrequiredIDataTableHeaderProps
- createHeaders only — DataTable props including headers definition and items (used to auto-generate columns when headers is omitted).
- options.groupByRef<IDataTableSortItem[]>
- createHeaders only — when set, prepends a data-table-group column to support row grouping.
- options.showSelectRef<boolean>
- createHeaders only — when true, prepends a data-table-select column for row checkboxes.
- options.showExpandRef<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
Consuming headers in a child component