Data Grid

warning
There are known styling issues with sortable columns when used in a NextJS app.

A data grid is a component designed to display large volumes in a structured and organized manner. It structures data into rows and columns, making it easy for users to visualize, analyze, and interact with the information. The data grid also improves user experience by providing features like sorting, filtering, and editing.

Props

NameTypeDescriptionDefault
Required
columns

GridColumn[]being GridColumn:

{ key: string; label: string; resizable?: boolean; sortable?: boolean; draggable?: boolean; textEditable?: boolean; summaryKey?: string; alignment?: "left" | "right" | "center"; }
Each GridColumn object has the following properties:
  • key: Key that will be rendered from each row in rows.
  • label: Label that will be used for the column header.
  • resizable: Whether the column is resizable or not.
  • sortable: Whether the column is sortable or not.
  • draggable: Whether the column can be dragged or not to another position or not.
  • textEditable: Whether the column cells are editable or not.
  • summaryKey: Value that will be rendered from the summaryRow
  • alignment: Sets the alignment inside the cells.
-
Required
rows
GridRow[] | HierarchyGridRow[] | ExpandableGridRow[]

Each one of them being in order:

{ [key: string]: React.ReactNode | undefined; }

GridRow & { childRows?: HierarchyGridRow[] | GridRow[]; }

GridRow & { expandedContent?: React.ReactNode; expandedContentHeight?: number; }

List of rows that will be rendered in each cell based on the key in each column.-
expandablebooleanWhether the rows can expand or not.-
summaryRowGridRowExtra row that will be always visible.-
selectablebooleanWhether the rows are selectable or not.-
selectedRowsSet<string | number>Set of selected rows. This prop is mandatory if selectable is set to true. The uniqueRowId key will be used to identify the each row.-
onSelectRows(selectedRows: Set<number | string>) => voidFunction called whenever the selected values changes. This prop is mandatory if selectable is set to true.The uniqueRowId key will be used to identify the rows.-
uniqueRowIdstringThis prop indicates the unique key that can be used to identify each row. This prop is mandatory if selectable is set to true, expandable is set to true or rows is of type HierarchyGridRow[].-
onGridRowsChange(rows: GridRow[] | HierarchyGridRow[] | ExpandableGridRow[]) => voidFunction called whenever a cell is edited.-

Examples

Basic usage

Selectable data grid

Expandable data grid

Hierarchical data grid

Hierarchical and selectable data grid