Nested field paths
Bind columns to nested properties with dot-notation paths, without flattening the data.
Live example
Expected behavior
Nested values display correctly. Removing an intermediate object shows an empty cell and does not throw. With suppression on, a key literally named 'address.city' is read instead of the nested path.
Source
const api = createGrid({
rows: customers,
columns: [
{ id: 'city', field: 'address.city' },
{ id: 'tier', field: 'account.tier' },
{ id: 'credit', field: 'account.limits.credit' },
],
suppressFieldDotNotation: false,
});
api.getCellValue(row, 'city'); // undefined when address is missingconst api = createGrid({
rows: customers,
columns: [
{ id: 'city', field: 'address.city' },
{ id: 'tier', field: 'account.tier' },
{ id: 'credit', field: 'account.limits.credit' },
],
suppressFieldDotNotation: false,
});
api.getCellValue(row, 'city'); // undefined when address is missingconst api = createGrid({
rows: customers,
columns: [
{ id: 'city', field: 'address.city' },
{ id: 'tier', field: 'account.tier' },
{ id: 'credit', field: 'account.limits.credit' },
],
suppressFieldDotNotation: false,
});
api.getCellValue(row, 'city'); // undefined when address is missingconst api = createGrid({
rows: customers,
columns: [
{ id: 'city', field: 'address.city' },
{ id: 'tier', field: 'account.tier' },
{ id: 'credit', field: 'account.limits.credit' },
],
suppressFieldDotNotation: false,
});
api.getCellValue(row, 'city'); // undefined when address is missing// JavaScript interop module
const api = createGrid({
rows: customers,
columns: [
{ id: 'city', field: 'address.city' },
{ id: 'tier', field: 'account.tier' },
{ id: 'credit', field: 'account.limits.credit' },
],
suppressFieldDotNotation: false,
});
api.getCellValue(row, 'city'); // undefined when address is missingAPI reference
| Kind | Name | Type | Description |
|---|---|---|---|
| Option | columnDef.field | — | A top-level key or a dot path such as address.city. |
| Option | suppressFieldDotNotation | — | Treats the whole field string as one key. |
| Method | getCellValue | — | Returns the resolved nested value. |
Acceptance criteria
- A path 'a.b.c' resolves to data.a.b.c (met)
- A null or undefined intermediate resolves to undefined and renders empty (met)
- When suppressFieldDotNotation is true, the full string is treated as one key (met)
- getCellValue returns the resolved nested value (met)
- Path resolution does not mutate the source data (met)