Skip to main content
zerotal

Documentation


Documentation / @zerotal/admin / index / Column

Class: Column

Defined in: admin/src/table/Column.ts:46

Constructors

Constructor

new Column(key): Column

Defined in: admin/src/table/Column.ts:67

Parameters

key

string

Returns

Column

Methods

make()

static make(key): Column

Defined in: admin/src/table/Column.ts:71

Parameters

key

string

Returns

Column


label()

label(label): this

Defined in: admin/src/table/Column.ts:76

Human label for the header. Defaults to a title-cased key.

Parameters

label

string

Returns

this


column()

column(name): this

Defined in: admin/src/table/Column.ts:87

The database column to query for search / sort / inline-edit, when it differs from the cell key. Use when the model exposes a camelCase accessor over a snake_case column: text("authorName").column("author_name"). The cell still reads row[key] (the accessor); only the SQL uses this column.

Parameters

name

string

Returns

this


getColumn()

getColumn(): string

Defined in: admin/src/table/Column.ts:93

The database column for query operations (defaults to the cell key).

Returns

string


sortable()

sortable(value?): this

Defined in: admin/src/table/Column.ts:98

Allow clicking the header to sort by this column (URL-driven).

Parameters

value?

boolean = true

Returns

this


searchable()

searchable(value?): this

Defined in: admin/src/table/Column.ts:104

Include this column in the list page's search.

Parameters

value?

boolean = true

Returns

this


filterable()

filterable(value?): this

Defined in: admin/src/table/Column.ts:118

Give this column its own filter box in the table header.

The list page derives the control from the column's kind — a text box for text, a yes/no switch for a toggle, the declared choices for a select — so a column usually needs nothing beyond this call. Header filters write into the same ?filters= parameter as declared filters and compose with tabs, search, sorting and pagination the same way.

Parameters

value?

boolean = true

Returns

this


align()

align(align): this

Defined in: admin/src/table/Column.ts:124

Horizontal alignment of the cell content.

Parameters

align

CellAlign

Returns

this


format()

format(fn): this

Defined in: admin/src/table/Column.ts:130

Custom value formatter (e.g. dates, currency).

Parameters

fn

(value, row) => string

Returns

this


badge()

badge(fn): this

Defined in: admin/src/table/Column.ts:136

Render the value as a colored badge; return null to fall back to text.

Parameters

fn

(value, row) => BadgeTone | null

Returns

this


toggle()

toggle(): this

Defined in: admin/src/table/Column.ts:142

Inline boolean toggle — flips the column on the record when clicked.

Returns

this


image()

image(): this

Defined in: admin/src/table/Column.ts:148

Render the value as an image (avatar / thumbnail).

Returns

this


circular()

circular(value?): this

Defined in: admin/src/table/Column.ts:154

Round image (avatar style).

Parameters

value?

boolean = true

Returns

this


color()

color(): this

Defined in: admin/src/table/Column.ts:160

Render the value as a color swatch + hex.

Returns

this


icon()

icon(): this

Defined in: admin/src/table/Column.ts:166

Render a boolean as a check / cross icon.

Returns

this


editSelect()

editSelect(options): this

Defined in: admin/src/table/Column.ts:172

Inline single-choice select — saves the chosen value on change.

Parameters

options

Record<string, string> | ColumnOption[]

Returns

this


editText()

editText(type?): this

Defined in: admin/src/table/Column.ts:181

Inline text input — saves on change/blur.

Parameters

type?

string = "text"

Returns

this


copyable()

copyable(value?): this

Defined in: admin/src/table/Column.ts:188

Show a copy-to-clipboard affordance on the cell.

Parameters

value?

boolean = true

Returns

this


summarize()

summarize(summary): this

Defined in: admin/src/table/Column.ts:196

Attach one or more summary aggregates, shown in the table/group footer.

Parameters

summary

ColumnSummary | ColumnSummary[]

Returns

this


sum()

sum(label?, format?): this

Defined in: admin/src/table/Column.ts:202

Sum the column (shorthand for summarize({ kind: "sum" })).

Parameters

label?

string

format?

(n) => string

Returns

this


avg()

avg(label?, format?): this

Defined in: admin/src/table/Column.ts:208

Average the column.

Parameters

label?

string

format?

(n) => string

Returns

this


count()

count(label?): this

Defined in: admin/src/table/Column.ts:214

Count the rows.

Parameters

label?

string

Returns

this


range()

range(label?, format?): this

Defined in: admin/src/table/Column.ts:220

Min–max range of the column.

Parameters

label?

string

format?

(n) => string

Returns

this


hasSummary()

hasSummary(): boolean

Defined in: admin/src/table/Column.ts:226

Whether this column has any summary aggregates.

Returns

boolean


computeSummaries()

computeSummaries(rows): SummaryResult[]

Defined in: admin/src/table/Column.ts:231

Compute this column's summaries over a set of rows.

Parameters

rows

Record<string, unknown>[]

Returns

SummaryResult[]


getLabel()

getLabel(): string

Defined in: admin/src/table/Column.ts:259

Resolved header label.

Returns

string


exportable()

exportable(value?): this

Defined in: admin/src/table/Column.ts:268

Whether this column may leave the panel in an export. Turn it off for anything that shouldn't land in a spreadsheet on someone's laptop.

Parameters

value?

boolean = true

Returns

this


render()

render(fn): this

Defined in: admin/src/table/Column.ts:284

Render this cell yourself, when no built-in kind fits — a sparkline, a progress bar, a stack of avatars.

text("health").render((v) => )

The renderer replaces the cell entirely, so .format() and .badge() no longer apply. Everything else about the column — its label, whether it sorts, whether it exports — still works, because those are the table's concerns rather than the cell's.

Parameters

fn

(value, row) => string | HtmlNode

Returns

this


raw()

raw(row): unknown

Defined in: admin/src/table/Column.ts:289

Parameters

row

Record<string, unknown>

Returns

unknown


cell()

cell(row): RenderableCell

Defined in: admin/src/table/Column.ts:294

Compute the display cell for a row.

Parameters

row

Record<string, unknown>

Returns

RenderableCell