HeaderCell

HeaderCell represents the model of a <th> element in <tr>.

Usage

id: string

A constant id that uniquely identifies the header cell in the row.

current: { attrs: HeaderCellAttributes; props: HeaderCellProps }

The attributes and plugin props of the <th> element as plain reactive values. current.attrs is ready to spread onto the element; current.props holds each plugin’s props, keyed by plugin name. Both update in place as table and plugin state change. Reads outside a template or effect return the current value, and server rendering produces the same markup.

<th {...cell.current.attrs} onclick={cell.current.props.sort.toggle}>
<th {...cell.current.attrs} onclick={cell.current.props.sort.toggle}>
Information:
See also Plugin View Model Extensions. v7 removed the attrs() and props() store methods; see Migrating to v7.

render: () => RenderConfig

Returns the render configuration of the header cell. Pass into Render#of.

<tr>
    {#each headerRow.cells as cell (cell.id)}
        <th {...cell.current.attrs}>
            <Render of={cell.render()} />
        </th>
    {/each}
</tr>
<tr>
    {#each headerRow.cells as cell (cell.id)}
        <th {...cell.current.attrs}>
            <Render of={cell.render()} />
        </th>
    {/each}
</tr>

isFlat: () => boolean

Returns true if the header cell is an instance of FlatHeaderCell.

isData: () => boolean

Returns true if the header cell is an instance of DataHeaderCell.

isFlatDisplay: () => boolean

Returns true if the header cell is an instance of FlatDisplayHeaderCell.

isGroup: () => boolean

Returns true if the header cell is an instance of GroupHeaderCell.

isGroupDisplay: () => boolean

Returns true if the header cell is an instance of GroupDisplayHeaderCell.

Variants

FlatHeaderCell

FlatHeaderCells represent header cells on the last header row in the table header.

DataHeaderCell

DataHeaderCell is a FlatHeaderCell that is backed by a specific data attribute.

DataHeaderCells are usually created with Table#column.

accessorKey?: string

The attribute key of the data item.

accessorFn?: (item) => unknown

The function to derive the data attribute.

FlatDisplayHeaderCell

FlatDisplayHeaderCell is a FlatHeaderCell that is not backed by any data attribute.

FlatDisplayHeaderCells are usually created with Table#display.

GroupHeaderCell

GroupHeaderCells represent header cells that span over other header cells.

ids: string[]

A list of ids of the cells that this group cell currently spans over.

ids is affected by column re-ordering and hiding.

allIds: string[]

A list of ids of the cells grouped by this group cell.

allIds is not affected by column re-ordering and hiding.

allId: string

A comma-joined string for allIds. allId should not be used as a unique identifier because there can be multiple groups with the same allId.

GroupDisplayHeaderCell

GroupDisplayHeaderCell is a GroupHeaderCell that is not backed by any data attribute.