Column definitions

Inferring columns from row data with defineColumnsFromRows.

Last updated August 8, 2026

defineColumnsFromRows inspects your row data and infers a type and alignment per field, one level into nested objects. Use it as a starting point, then override or extend individual columns.

Column definition shape#

PropTypeDescription
fieldFieldPath<Row> | stringPath to this column's value, e.g. "Application.Id".
idstringStable identity for sizing/order state. Defaults to field.
headerTemplateNode | (() => Node)Header content, or a function returning it at render time.
cellTemplate(context: CellTemplateContext<Row>) => NodeRenders this column's cells in place of the raw value.
typeColumnTypeThe value type of this column's cells, e.g. "currency".
alignment"left" | "center" | "right"Alignment of this column's cells. Falls back to type.
widthnumberWidth in px this column starts at.
minWidthnumberLower bound a resize may not drag below.
maxWidthnumberUpper bound a resize may not drag above.
resizablebooleanWhether this column can be resized, overriding the grid-level default.
reorderablebooleanWhether this column can be dragged to a new position, overriding the grid-level default.
wrap{ header?, cells? }Lets this column's header and/or cell text wrap onto multiple lines instead of truncating.
headerClassNamestringExtra class names appended to this column's th.
cellClassNamestringExtra class names appended to this column's td, on every row.

Inferred columns#

defineColumnsFromRows

Live example
IdServiceEnvironment NameEnvironment RegionStatusCost
1checkout-apiproductionus-east-1healthy1240.5
2billing-workerproductioneu-west-1degraded860.2
3search-indexstagingus-east-1healthy92.75
4notificationsproductionus-west-2down305.4
5analytics-pipelinestagingeu-west-1healthy145
import { defineColumnsFromRows } from "@gridkitjs/core";
import { DataGridComponent } from "@gridkitjs/react";

const columns = defineColumnsFromRows(rows);

<DataGridComponent columns={columns} dataSource={rows} borders="horizontal" />;
FunctionTypeDescription
defineColumnsFromRows(rows)readonly ColumnDefinition<Row>[]Infers a type and alignment per field, one level into nested objects.
accessDotted(obj, path)unknownReads a value at a dotted path, e.g. "Application.Id".
alignmentForType(type)ColumnAlignmentAlignment a column type defaults to — "right" for numbers.
resolveColumnLabel(column)stringThe label a column's header falls back to when it sets no headerTemplate.
buildKeyShortcuts(capabilities)stringThe aria-keyshortcuts string for a column header, naming only the keys that column responds to.
Edit this page on GitHub