Skip to content

Data & Row Types

GridRow

Every row object must extend GridRow, which requires an id: string field:

ts
import type { GridRow } from '@itsmemyk/react-tree-grid/grid'

interface Product extends GridRow {
  name: string
  price: number
  inStock: boolean
}

GridRow also supports these reserved keys:

KeyTypeDescription
idstringUnique row identifier (required)
hiddenbooleanHide this row without removing it
$heightnumberOverride row height in pixels
$cssstringExtra CSS class applied to the row

TreeGridRow

TreeGridRow extends GridRow with hierarchy fields:

ts
import type { TreeGridRow } from '@itsmemyk/react-tree-grid/treegrid'

interface OrgRow extends TreeGridRow {
  name: string
  role: string
}

Additional fields:

KeyTypeDescription
parentstringID of parent row (omit for root rows)
itemsTreeGridRow[]Nested children (alternative to flat parent references)
$openedbooleanWhether this node starts expanded

You can mix parent references (flat array) and nested items — the grid normalises both.

TreeNode

Used by the Tree component:

ts
import type { TreeNode } from '@itsmemyk/react-tree-grid/tree'

const nodes: TreeNode[] = [
  {
    id: 'root',
    value: 'Documents',
    $opened: true,
    items: [
      { id: 'file1', value: 'Report.pdf' },
    ],
  },
]
KeyTypeDescription
idstringUnique node identifier
valuestringDisplay label
iconReactNodeCustom icon before the label
itemsTreeNode[]Child nodes
disabledbooleanDisable interaction
$openedbooleanStart expanded

Using a DataStore

For large or server-driven datasets, pass a DataStore instead of a plain array:

ts
import { DataStore } from '@itsmemyk/react-tree-grid'

const store = new DataStore({ data: largeArray })

<Grid columns={columns} store={store} style={{ width: 800, height: 600 }} />

DataStore supports filtering, sorting, and pagination without re-rendering the full dataset.

Released under the MIT License.