Column Base
LyteNyte Grid applies a set of default options to the columns you provide. You can override these defaults through the column base object.
Overriding Defaults
Every column in LyteNyte Grid extends a default column specification. The grid uses this specification to fill in any values omitted from your column definitions. For example:
const columns = [{ id: "name" }, { id: "email", width: 200 }];
The name column uses the default width of 150, while the email
column uses its specified width of 200. Every property on the column
interface has a default value. Refer to the
Column API reference for details.
To override these defaults, provide a columnBase object.
LyteNyte Grid merges this object with the built-in defaults,
overriding any specified properties.
For example, in the code below the default column width becomes 100.
You can override any default property on the column specification except
those properties that have been explicitly excluded, such as field or pin.
function MyGrid() {const grid = Grid.useLyteNyte({columnBase: { width: 100 },columns,});}
A common pattern is to set a default cell renderer or header renderer. The demo below creates a heatmap of temperatures using a shared default cell renderer:
Monthly Temperatures Heatmap
The demo overrides width, widthMin, and widthFlex. Since
those defaults are tailored for monthly temperature columns,
the year column must specify its own values:
const columns: Column<MonthlyTemperature>[] = [{ id: "year", cellRenderer: YearCell, width: 100 },{ id: "Jan" },// other columns];
Exclusions From the Base
The columnBase property cannot override every column option.
In particular, pin and field must be set per column and
cannot be defined through the base. These properties apply only
to specific columns, not all columns, so this limitation
is intentional. See the ColumnBase API reference
for the full list of overridable properties.
Next Steps
- Column Resizing: Change column widths programmatically or via user interaction.
- Column ID & Name: Define user-friendly column names and ensure unique IDs.
- Column Moving: Reorder columns programmatically or through drag-and-drop.
- Column Field: Control how a column retrieves its value for each cell.
Overview
LyteNyte Grid uses columns to define the data displayed in the grid's viewport. This guide details how to use columns to configure dynamic views.
Column ID & Name
Every column in LyteNyte Grid must have a unique ID. LyteNyte Grid uses this ID to manage column related state. When the ID is not human readable, you can provide a display name.