@alaarab/ogrid-mcp 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +68 -0
- package/bundled-docs/api/README.md +94 -0
- package/bundled-docs/api/column-def.mdx +379 -0
- package/bundled-docs/api/components-column-chooser.mdx +310 -0
- package/bundled-docs/api/components-column-header-filter.mdx +363 -0
- package/bundled-docs/api/components-datagrid-table.mdx +316 -0
- package/bundled-docs/api/components-pagination-controls.mdx +344 -0
- package/bundled-docs/api/components-sidebar.mdx +427 -0
- package/bundled-docs/api/components-status-bar.mdx +309 -0
- package/bundled-docs/api/grid-api.mdx +299 -0
- package/bundled-docs/api/js-api.mdx +198 -0
- package/bundled-docs/api/ogrid-props.mdx +244 -0
- package/bundled-docs/api/types.mdx +640 -0
- package/bundled-docs/features/cell-references.mdx +225 -0
- package/bundled-docs/features/column-chooser.mdx +279 -0
- package/bundled-docs/features/column-groups.mdx +290 -0
- package/bundled-docs/features/column-pinning.mdx +282 -0
- package/bundled-docs/features/column-reordering.mdx +359 -0
- package/bundled-docs/features/column-types.mdx +181 -0
- package/bundled-docs/features/context-menu.mdx +216 -0
- package/bundled-docs/features/csv-export.mdx +227 -0
- package/bundled-docs/features/editing.mdx +377 -0
- package/bundled-docs/features/filtering.mdx +330 -0
- package/bundled-docs/features/formulas.mdx +381 -0
- package/bundled-docs/features/grid-api.mdx +311 -0
- package/bundled-docs/features/keyboard-navigation.mdx +236 -0
- package/bundled-docs/features/pagination.mdx +245 -0
- package/bundled-docs/features/performance.mdx +433 -0
- package/bundled-docs/features/row-selection.mdx +256 -0
- package/bundled-docs/features/server-side-data.mdx +291 -0
- package/bundled-docs/features/sidebar.mdx +234 -0
- package/bundled-docs/features/sorting.mdx +241 -0
- package/bundled-docs/features/spreadsheet-selection.mdx +201 -0
- package/bundled-docs/features/status-bar.mdx +205 -0
- package/bundled-docs/features/toolbar.mdx +284 -0
- package/bundled-docs/features/virtual-scrolling.mdx +624 -0
- package/bundled-docs/getting-started/installation.mdx +216 -0
- package/bundled-docs/getting-started/overview.mdx +151 -0
- package/bundled-docs/getting-started/quick-start.mdx +425 -0
- package/bundled-docs/getting-started/vanilla-js.mdx +191 -0
- package/bundled-docs/guides/accessibility.mdx +550 -0
- package/bundled-docs/guides/controlled-vs-uncontrolled.mdx +153 -0
- package/bundled-docs/guides/custom-cell-editors.mdx +201 -0
- package/bundled-docs/guides/framework-showcase.mdx +200 -0
- package/bundled-docs/guides/mcp-live-testing.mdx +291 -0
- package/bundled-docs/guides/mcp.mdx +172 -0
- package/bundled-docs/guides/migration-from-ag-grid.mdx +223 -0
- package/bundled-docs/guides/theming.mdx +211 -0
- package/dist/esm/bridge-client.d.ts +87 -0
- package/dist/esm/bridge-client.js +162 -0
- package/dist/esm/index.js +1060 -0
- package/package.json +43 -0
package/README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# @alaarab/ogrid-mcp
|
|
2
|
+
|
|
3
|
+
MCP (Model Context Protocol) server for OGrid documentation. Lets AI assistants search and retrieve OGrid docs, code examples, and API references across all supported frameworks (React, Angular, Vue, vanilla JS).
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
### Claude Desktop
|
|
8
|
+
|
|
9
|
+
Add this to your Claude Desktop config (`claude_desktop_config.json`):
|
|
10
|
+
|
|
11
|
+
```json
|
|
12
|
+
{
|
|
13
|
+
"mcpServers": {
|
|
14
|
+
"ogrid": {
|
|
15
|
+
"command": "npx",
|
|
16
|
+
"args": ["-y", "@alaarab/ogrid-mcp"]
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Claude Code
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
claude mcp add ogrid -- npx -y @alaarab/ogrid-mcp
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Direct execution
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npx @alaarab/ogrid-mcp
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Tools
|
|
35
|
+
|
|
36
|
+
The server exposes 5 tools:
|
|
37
|
+
|
|
38
|
+
| Tool | Description |
|
|
39
|
+
|------|-------------|
|
|
40
|
+
| `search_docs` | Search OGrid documentation by keyword. Returns matching docs with title, description, and content excerpt. |
|
|
41
|
+
| `list_docs` | List available documentation pages, optionally filtered by category (`features`, `getting-started`, `guides`, `api`). |
|
|
42
|
+
| `get_docs` | Get the full content of a documentation page by its path. |
|
|
43
|
+
| `get_code_example` | Find code examples matching a query, optionally filtered by framework (`react`, `angular`, `vue`, `js`). |
|
|
44
|
+
| `detect_version` | Detect which OGrid version and framework is installed in the user's project by reading their package.json. |
|
|
45
|
+
|
|
46
|
+
## Resources
|
|
47
|
+
|
|
48
|
+
| URI | Description |
|
|
49
|
+
|-----|-------------|
|
|
50
|
+
| `ogrid://quick-reference` | Key props, install commands, and common patterns. |
|
|
51
|
+
| `ogrid://migration-guide` | Full migration guide from AG Grid to OGrid with side-by-side API mapping. |
|
|
52
|
+
| `ogrid://docs/{path}` | Any documentation page by path (e.g. `ogrid://docs/features/sorting`). |
|
|
53
|
+
|
|
54
|
+
## Prompts
|
|
55
|
+
|
|
56
|
+
| Name | Description |
|
|
57
|
+
|------|-------------|
|
|
58
|
+
| `migrate-from-ag-grid` | Step-by-step guide to migrate from AG Grid to OGrid. Returns the full migration guide with instructions for the AI to analyze your AG Grid usage and provide specific migration steps. |
|
|
59
|
+
|
|
60
|
+
## Environment Variables
|
|
61
|
+
|
|
62
|
+
| Variable | Description | Default |
|
|
63
|
+
|----------|-------------|---------|
|
|
64
|
+
| `OGRID_DOCS_PATH` | Absolute path to the docs directory containing `.mdx`/`.md` files. | `packages/docs/docs` relative to the package install location |
|
|
65
|
+
|
|
66
|
+
## How it works
|
|
67
|
+
|
|
68
|
+
On startup, the server indexes all `.mdx` and `.md` files from the docs directory. It parses frontmatter (title, description), extracts fenced code blocks with framework detection, and builds a searchable in-memory index. Search results are ranked by title match, description match, content density, and category relevance.
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# API Reference
|
|
2
|
+
|
|
3
|
+
Complete API documentation for OGrid components, types, and interfaces.
|
|
4
|
+
|
|
5
|
+
## Components
|
|
6
|
+
|
|
7
|
+
- **[DataGridTable](./components-datagrid-table.mdx)** — Core data grid component that renders the table, headers, rows, and cells
|
|
8
|
+
- **[ColumnHeaderFilter](./components-column-header-filter.mdx)** — Column header with sorting and filtering UI (text, multi-select, people, date)
|
|
9
|
+
- **[ColumnChooser](./components-column-chooser.mdx)** — Dropdown for showing/hiding columns
|
|
10
|
+
- **[PaginationControls](./components-pagination-controls.mdx)** — Pagination UI with page navigation and page size selector
|
|
11
|
+
- **[StatusBar](./components-status-bar.mdx)** — Status bar with row counts and cell aggregations
|
|
12
|
+
- **[SideBar](./components-sidebar.mdx)** — Collapsible sidebar with columns and filters panels
|
|
13
|
+
|
|
14
|
+
## Configuration
|
|
15
|
+
|
|
16
|
+
- **[OGrid Props](./ogrid-props.mdx)** — Top-level OGrid component props (client-side and server-side modes)
|
|
17
|
+
- **[Column Definition](./column-def.mdx)** — Complete column definition reference (IColumnDef, IColumnGroupDef, cell editors, filters)
|
|
18
|
+
- **[Grid API](./grid-api.mdx)** — Imperative grid API (IOGridApi) for programmatic control
|
|
19
|
+
- **[JS API](./js-api.mdx)** — Vanilla JS API reference (OGrid class, state classes, components)
|
|
20
|
+
|
|
21
|
+
## Types
|
|
22
|
+
|
|
23
|
+
- **[Types Reference](./types.mdx)** — All shared TypeScript types:
|
|
24
|
+
- **Data Types:** `RowId`, `FilterValue`, `IFilters`, `IDataSource`, `IFetchParams`, `IPageResult`
|
|
25
|
+
- **Selection:** `RowSelectionMode`, `IActiveCell`, `ISelectionRange`, `IRowSelectionChangeEvent`
|
|
26
|
+
- **Editing:** `ICellEditorProps`, `ICellValueChangedEvent`, `CellEditorParams`
|
|
27
|
+
- **UI:** `IStatusBarProps`, `ISideBarDef`, `UserLike`
|
|
28
|
+
- **State:** `IGridColumnState`, `IVirtualScrollConfig`
|
|
29
|
+
|
|
30
|
+
## Quick Links
|
|
31
|
+
|
|
32
|
+
### Getting Started
|
|
33
|
+
- [Installation](/docs/getting-started/installation)
|
|
34
|
+
- [Quick Start](/docs/getting-started/quick-start)
|
|
35
|
+
- [Framework Showcase](/docs/guides/framework-showcase)
|
|
36
|
+
|
|
37
|
+
### Features
|
|
38
|
+
- [Sorting](/docs/features/sorting)
|
|
39
|
+
- [Filtering](/docs/features/filtering)
|
|
40
|
+
- [Pagination](/docs/features/pagination)
|
|
41
|
+
- [Row Selection](/docs/features/row-selection)
|
|
42
|
+
- [Spreadsheet Selection](/docs/features/spreadsheet-selection)
|
|
43
|
+
- [Editing](/docs/features/editing)
|
|
44
|
+
- [Column Chooser](/docs/features/column-chooser)
|
|
45
|
+
- [Server-Side Data](/docs/features/server-side-data)
|
|
46
|
+
- [Virtual Scrolling](/docs/features/virtual-scrolling)
|
|
47
|
+
- [Sidebar](/docs/features/sidebar)
|
|
48
|
+
|
|
49
|
+
## Type Imports
|
|
50
|
+
|
|
51
|
+
All types can be imported from any OGrid package:
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
// React packages
|
|
55
|
+
IColumnDef,
|
|
56
|
+
IOGridApi,
|
|
57
|
+
IOGridProps,
|
|
58
|
+
IDataSource,
|
|
59
|
+
ICellEditorProps,
|
|
60
|
+
IFilters,
|
|
61
|
+
FilterValue,
|
|
62
|
+
RowId,
|
|
63
|
+
} from '@alaarab/ogrid-react-radix';
|
|
64
|
+
|
|
65
|
+
// Angular packages
|
|
66
|
+
IColumnDef,
|
|
67
|
+
IOGridApi,
|
|
68
|
+
IDataSource,
|
|
69
|
+
} from '@alaarab/ogrid-angular-material';
|
|
70
|
+
|
|
71
|
+
// Vue packages
|
|
72
|
+
IColumnDef,
|
|
73
|
+
IOGridApi,
|
|
74
|
+
IDataSource,
|
|
75
|
+
} from '@alaarab/ogrid-vue-vuetify';
|
|
76
|
+
|
|
77
|
+
// Vanilla JS
|
|
78
|
+
IColumnDef,
|
|
79
|
+
IDataSource,
|
|
80
|
+
} from '@alaarab/ogrid-js';
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Framework-Specific APIs
|
|
84
|
+
|
|
85
|
+
Each framework has idiomatic APIs:
|
|
86
|
+
|
|
87
|
+
| Framework | Orchestration | State Hook/Service | Props Pattern |
|
|
88
|
+
|-----------|---------------|-------------------|---------------|
|
|
89
|
+
| **React** | `useOGrid()` hook | `useDataGridState()` | Individual props |
|
|
90
|
+
| **Angular** | `OGridService` | `DataGridStateService` | Signal-based inputs |
|
|
91
|
+
| **Vue** | `useOGrid()` composable | `useDataGridState()` | Individual props or `:grid-props` |
|
|
92
|
+
| **Vanilla JS** | `OGrid` class | `GridState` class | Constructor options |
|
|
93
|
+
|
|
94
|
+
See the [Framework Showcase](/docs/guides/framework-showcase) for detailed comparisons and examples.
|
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 2
|
|
3
|
+
title: Column Definition
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Column Definition
|
|
7
|
+
|
|
8
|
+
Complete reference for column definitions, column groups, cell editors, and related types.
|
|
9
|
+
|
|
10
|
+
## IColumnMeta
|
|
11
|
+
|
|
12
|
+
Base metadata shared by all column definitions. These properties control how a column appears and behaves in the grid header.
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
interface IColumnMeta {
|
|
16
|
+
columnId: string;
|
|
17
|
+
name: string;
|
|
18
|
+
type?: 'text' | 'numeric' | 'date' | 'boolean';
|
|
19
|
+
sortable?: boolean;
|
|
20
|
+
filterable?: IColumnFilterDef;
|
|
21
|
+
defaultVisible?: boolean;
|
|
22
|
+
required?: boolean;
|
|
23
|
+
minWidth?: number;
|
|
24
|
+
defaultWidth?: number;
|
|
25
|
+
idealWidth?: number;
|
|
26
|
+
pinned?: 'left' | 'right';
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
| Name | Type | Default | Description |
|
|
31
|
+
|------|------|---------|-------------|
|
|
32
|
+
| `columnId` | `string` | **Required** | Unique identifier for the column. Used as the key for sorting, filtering, visibility, and state persistence. Also used as the default field name for `valueGetter` if none is provided. |
|
|
33
|
+
| `name` | `string` | **Required** | Display name shown in the column header. |
|
|
34
|
+
| `type` | `'text' \| 'numeric' \| 'date' \| 'boolean'` | `undefined` | Column data type. Affects alignment, default editor, default filter, and display formatting. `'numeric'` right-aligns cells; `'date'` applies date formatting and a date picker editor; `'boolean'` centers cells and uses a checkbox editor. |
|
|
35
|
+
| `sortable` | `boolean` | `true` | Whether the column header is clickable for sorting. |
|
|
36
|
+
| `filterable` | `IColumnFilterDef` | `undefined` | Filter configuration. When provided, a filter icon appears in the column header. See [IColumnFilterDef](#icolumnfilterdef) below. |
|
|
37
|
+
| `defaultVisible` | `boolean` | `true` | Whether the column is visible by default. Columns with `defaultVisible: false` can be shown via the column chooser. |
|
|
38
|
+
| `required` | `boolean` | `false` | When `true`, the column cannot be hidden via the column chooser. |
|
|
39
|
+
| `minWidth` | `number` | `undefined` | Minimum column width in pixels. The column cannot be resized below this value. |
|
|
40
|
+
| `defaultWidth` | `number` | `undefined` | Default column width in pixels. |
|
|
41
|
+
| `idealWidth` | `number` | `undefined` | Preferred column width in pixels. Used by the grid's auto-sizing algorithm. |
|
|
42
|
+
| `pinned` | `'left' \| 'right'` | `undefined` | Pin the column to the left or right edge of the grid. Pinned columns remain visible when scrolling horizontally. |
|
|
43
|
+
|
|
44
|
+
## IColumnDef<T>
|
|
45
|
+
|
|
46
|
+
Extends `IColumnMeta` with rendering, editing, and data access properties. The `renderCell` and `cellStyle` properties are React-specific additions; Angular and Vue packages have equivalent rendering mechanisms in their respective component APIs.
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
interface IColumnDef<T> extends IColumnMeta {
|
|
50
|
+
renderCell?: (item: T) => ReactNode;
|
|
51
|
+
compare?: (a: T, b: T) => number;
|
|
52
|
+
valueGetter?: (item: T) => unknown;
|
|
53
|
+
valueFormatter?: (value: unknown, item: T) => string;
|
|
54
|
+
clipboardFormatter?: (value: unknown, item: T) => string;
|
|
55
|
+
valueParser?: (params: IValueParserParams<T>) => unknown;
|
|
56
|
+
cellStyle?: CSSProperties | ((item: T) => CSSProperties);
|
|
57
|
+
editable?: boolean | ((item: T) => boolean);
|
|
58
|
+
cellEditor?: 'text' | 'select' | 'checkbox' | 'richSelect' | 'date' | ComponentType<ICellEditorProps<T>>;
|
|
59
|
+
cellEditorPopup?: boolean;
|
|
60
|
+
cellEditorParams?: CellEditorParams;
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Rendering
|
|
65
|
+
|
|
66
|
+
| Name | Type | Default | Description |
|
|
67
|
+
|------|------|---------|-------------|
|
|
68
|
+
| `renderCell` | `(item: T) => ReactNode` | `undefined` | Custom cell renderer. Receives the row data and returns JSX. When not provided, the grid displays the raw value from `valueGetter` or the field matching `columnId`. |
|
|
69
|
+
| `cellStyle` | `CSSProperties \| ((item: T) => CSSProperties)` | `undefined` | Custom styles applied to the cell. Can be a static style object or a function that returns styles based on the row data. |
|
|
70
|
+
|
|
71
|
+
### Data Access
|
|
72
|
+
|
|
73
|
+
| Name | Type | Default | Description |
|
|
74
|
+
|------|------|---------|-------------|
|
|
75
|
+
| `valueGetter` | `(item: T) => unknown` | `undefined` | Extracts the raw value from a row for sorting, filtering, editing, and display. When not provided, the grid reads `item[columnId]`. |
|
|
76
|
+
| `valueFormatter` | `(value: unknown, item: T) => string` | `undefined` | Formats the raw value for display. Receives the value from `valueGetter` and the row data. Also used for clipboard copy when `clipboardFormatter` is not set. |
|
|
77
|
+
| `clipboardFormatter` | `(value: unknown, item: T) => string` | `undefined` | Formats the raw value specifically for clipboard copy. When set, overrides `valueFormatter` for copy/paste operations. |
|
|
78
|
+
| `valueParser` | `(params: IValueParserParams<T>) => unknown` | `undefined` | Parses a user-entered string back into the data type expected by your model. Used during cell editing and paste operations. |
|
|
79
|
+
| `compare` | `(a: T, b: T) => number` | `undefined` | Custom sort comparator. Returns a negative number if `a` comes before `b`, positive if after, or `0` if equal. When not provided, the grid uses a default comparison on the `valueGetter` result. |
|
|
80
|
+
|
|
81
|
+
### Editing
|
|
82
|
+
|
|
83
|
+
| Name | Type | Default | Description |
|
|
84
|
+
|------|------|---------|-------------|
|
|
85
|
+
| `editable` | `boolean \| ((item: T) => boolean)` | `false` | Whether cells in this column are editable. A function allows per-row control. The grid-level `editable` prop must also be `true` for editing to work. |
|
|
86
|
+
| `cellEditor` | `'text' \| 'select' \| 'checkbox' \| 'richSelect' \| 'date' \| ComponentType<ICellEditorProps<T>>` | `'text'` | The editor to use when a cell enters edit mode. Built-in editors: `'text'` (text input), `'select'` (dropdown), `'checkbox'` (toggle), `'richSelect'` (searchable dropdown), `'date'` (date picker). You can also pass a custom React component. |
|
|
87
|
+
| `cellEditorPopup` | `boolean` | `false` | When `true`, the cell editor renders in a popup overlay instead of inline within the cell. |
|
|
88
|
+
| `cellEditorParams` | `CellEditorParams` | `undefined` | Additional parameters passed to the cell editor. The shape depends on the editor type. See [CellEditorParams](#celleditorparams) below. |
|
|
89
|
+
|
|
90
|
+
## IColumnFilterDef
|
|
91
|
+
|
|
92
|
+
Configuration for column header filters.
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
interface IColumnFilterDef {
|
|
96
|
+
type: 'text' | 'multiSelect' | 'people' | 'date';
|
|
97
|
+
filterField?: string;
|
|
98
|
+
optionsSource?: 'api' | 'static' | 'years';
|
|
99
|
+
options?: string[];
|
|
100
|
+
yearsCount?: number;
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
| Name | Type | Default | Description |
|
|
105
|
+
|------|------|---------|-------------|
|
|
106
|
+
| `type` | `'text' \| 'multiSelect' \| 'people' \| 'date'` | **Required** | Filter type. `'text'` shows a text input. `'multiSelect'` shows a list of checkboxes. `'people'` shows a people picker with search. `'date'` shows a date range picker with from/to date inputs. |
|
|
107
|
+
| `filterField` | `string` | `columnId` | The field name to use in the `IFilters` record. Defaults to the column's `columnId`. Useful when multiple columns filter on the same field. |
|
|
108
|
+
| `optionsSource` | `'api' \| 'static' \| 'years'` | `undefined` | Where multiSelect options come from. `'static'` uses the `options` array. `'api'` calls `dataSource.fetchFilterOptions()`. `'years'` auto-generates a list of years. |
|
|
109
|
+
| `options` | `string[]` | `undefined` | Static list of filter options for `optionsSource: 'static'`. |
|
|
110
|
+
| `yearsCount` | `number` | `undefined` | Number of years to generate when `optionsSource: 'years'`. |
|
|
111
|
+
|
|
112
|
+
### Filter Type Examples
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
// Text filter
|
|
116
|
+
{ columnId: 'name', name: 'Name', filterable: { type: 'text' } }
|
|
117
|
+
|
|
118
|
+
// Multi-select with static options
|
|
119
|
+
{
|
|
120
|
+
columnId: 'status',
|
|
121
|
+
name: 'Status',
|
|
122
|
+
filterable: {
|
|
123
|
+
type: 'multiSelect',
|
|
124
|
+
optionsSource: 'static',
|
|
125
|
+
options: ['Active', 'Inactive', 'Pending'],
|
|
126
|
+
},
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Multi-select with server-side options
|
|
130
|
+
{
|
|
131
|
+
columnId: 'department',
|
|
132
|
+
name: 'Department',
|
|
133
|
+
filterable: { type: 'multiSelect', optionsSource: 'api' },
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// People filter
|
|
137
|
+
{
|
|
138
|
+
columnId: 'assignee',
|
|
139
|
+
name: 'Assignee',
|
|
140
|
+
filterable: { type: 'people' },
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Year filter
|
|
144
|
+
{
|
|
145
|
+
columnId: 'year',
|
|
146
|
+
name: 'Year',
|
|
147
|
+
filterable: { type: 'multiSelect', optionsSource: 'years', yearsCount: 10 },
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## IColumnGroupDef<T>
|
|
152
|
+
|
|
153
|
+
Defines a group of columns rendered under a shared multi-row header.
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
interface IColumnGroupDef<T> {
|
|
157
|
+
headerName: string;
|
|
158
|
+
children: (IColumnGroupDef<T> | IColumnDef<T>)[];
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
| Name | Type | Default | Description |
|
|
163
|
+
|------|------|---------|-------------|
|
|
164
|
+
| `headerName` | `string` | **Required** | Display name for the column group header. Rendered centered above its child columns. |
|
|
165
|
+
| `children` | `(IColumnGroupDef<T> \| IColumnDef<T>)[]` | **Required** | Child columns or nested column groups. Groups can be nested to arbitrary depth, producing multi-row headers. |
|
|
166
|
+
|
|
167
|
+
### Column Group Example
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
const columns = [
|
|
171
|
+
{ columnId: 'name', name: 'Name' },
|
|
172
|
+
{
|
|
173
|
+
headerName: 'Contact Info',
|
|
174
|
+
children: [
|
|
175
|
+
{ columnId: 'email', name: 'Email' },
|
|
176
|
+
{ columnId: 'phone', name: 'Phone' },
|
|
177
|
+
],
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
headerName: 'Address',
|
|
181
|
+
children: [
|
|
182
|
+
{ columnId: 'city', name: 'City' },
|
|
183
|
+
{ columnId: 'state', name: 'State' },
|
|
184
|
+
{ columnId: 'zip', name: 'ZIP' },
|
|
185
|
+
],
|
|
186
|
+
},
|
|
187
|
+
];
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
This renders as:
|
|
191
|
+
|
|
192
|
+
| Name | Contact Info || Address |||
|
|
193
|
+
|------|-------|-------|------|-------|-----|
|
|
194
|
+
| | Email | Phone | City | State | ZIP |
|
|
195
|
+
|
|
196
|
+
## ICellEditorProps<T>
|
|
197
|
+
|
|
198
|
+
Props received by custom cell editor components.
|
|
199
|
+
|
|
200
|
+
```typescript
|
|
201
|
+
interface ICellEditorProps<T> {
|
|
202
|
+
value: unknown;
|
|
203
|
+
onValueChange: (value: unknown) => void;
|
|
204
|
+
onCommit: () => void;
|
|
205
|
+
onCancel: () => void;
|
|
206
|
+
item: T;
|
|
207
|
+
column: IColumnDef<T>;
|
|
208
|
+
cellEditorParams?: CellEditorParams;
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
| Name | Type | Description |
|
|
213
|
+
|------|------|-------------|
|
|
214
|
+
| `value` | `unknown` | The current cell value. |
|
|
215
|
+
| `onValueChange` | `(value: unknown) => void` | Call this to update the pending value as the user types or makes a selection. |
|
|
216
|
+
| `onCommit` | `() => void` | Call this to commit the current value and exit edit mode. Typically bound to Enter or blur. |
|
|
217
|
+
| `onCancel` | `() => void` | Call this to discard changes and exit edit mode. Typically bound to Escape. |
|
|
218
|
+
| `item` | `T` | The full row data object. |
|
|
219
|
+
| `column` | `IColumnDef<T>` | The column definition for the cell being edited. |
|
|
220
|
+
| `cellEditorParams` | `CellEditorParams` | Additional parameters from the column definition's `cellEditorParams`. |
|
|
221
|
+
|
|
222
|
+
### Custom Cell Editor Example
|
|
223
|
+
|
|
224
|
+
```typescript
|
|
225
|
+
|
|
226
|
+
function DateEditor({ value, onValueChange, onCommit, onCancel }: ICellEditorProps<MyRow>) {
|
|
227
|
+
return (
|
|
228
|
+
<input
|
|
229
|
+
type="date"
|
|
230
|
+
value={value as string}
|
|
231
|
+
onChange={(e) => onValueChange(e.target.value)}
|
|
232
|
+
onKeyDown={(e) => {
|
|
233
|
+
if (e.key === 'Enter') onCommit();
|
|
234
|
+
if (e.key === 'Escape') onCancel();
|
|
235
|
+
}}
|
|
236
|
+
onBlur={onCommit}
|
|
237
|
+
autoFocus
|
|
238
|
+
/>
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const columns = [
|
|
243
|
+
{
|
|
244
|
+
columnId: 'dueDate',
|
|
245
|
+
name: 'Due Date',
|
|
246
|
+
editable: true,
|
|
247
|
+
cellEditor: DateEditor,
|
|
248
|
+
},
|
|
249
|
+
];
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
## CellEditorParams
|
|
253
|
+
|
|
254
|
+
Parameters passed to built-in cell editors via the `cellEditorParams` property on a column definition. The shape varies by editor type.
|
|
255
|
+
|
|
256
|
+
### Select Editor
|
|
257
|
+
|
|
258
|
+
```typescript
|
|
259
|
+
{
|
|
260
|
+
cellEditor: 'select',
|
|
261
|
+
cellEditorParams: {
|
|
262
|
+
values: ['Option A', 'Option B', 'Option C'],
|
|
263
|
+
},
|
|
264
|
+
}
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
| Name | Type | Description |
|
|
268
|
+
|------|------|-------------|
|
|
269
|
+
| `values` | `string[]` | List of options for the select dropdown. |
|
|
270
|
+
|
|
271
|
+
### Rich Select Editor
|
|
272
|
+
|
|
273
|
+
```typescript
|
|
274
|
+
{
|
|
275
|
+
cellEditor: 'richSelect',
|
|
276
|
+
cellEditorParams: {
|
|
277
|
+
values: ['Active', 'Inactive', 'Pending'],
|
|
278
|
+
formatValue: (value: string) => value.toUpperCase(),
|
|
279
|
+
},
|
|
280
|
+
}
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
| Name | Type | Description |
|
|
284
|
+
|------|------|-------------|
|
|
285
|
+
| `values` | `string[]` | List of options for the searchable dropdown. |
|
|
286
|
+
| `formatValue` | `(value: string) => string` | Optional function to format how each option is displayed. |
|
|
287
|
+
|
|
288
|
+
## ICellValueChangedEvent<T>
|
|
289
|
+
|
|
290
|
+
Event object passed to `onCellValueChanged` after a cell edit is committed.
|
|
291
|
+
|
|
292
|
+
```typescript
|
|
293
|
+
interface ICellValueChangedEvent<T> {
|
|
294
|
+
item: T;
|
|
295
|
+
columnId: string;
|
|
296
|
+
oldValue: unknown;
|
|
297
|
+
newValue: unknown;
|
|
298
|
+
rowIndex: number;
|
|
299
|
+
}
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
| Name | Type | Description |
|
|
303
|
+
|------|------|-------------|
|
|
304
|
+
| `item` | `T` | The row data object (before the change). |
|
|
305
|
+
| `columnId` | `string` | The column ID of the edited cell. |
|
|
306
|
+
| `oldValue` | `unknown` | The value before editing. |
|
|
307
|
+
| `newValue` | `unknown` | The value after editing. |
|
|
308
|
+
| `rowIndex` | `number` | The row index of the edited cell. |
|
|
309
|
+
|
|
310
|
+
## Complete Column Definition Example
|
|
311
|
+
|
|
312
|
+
```typescript
|
|
313
|
+
|
|
314
|
+
interface Employee {
|
|
315
|
+
id: number;
|
|
316
|
+
name: string;
|
|
317
|
+
department: string;
|
|
318
|
+
salary: number;
|
|
319
|
+
startDate: string;
|
|
320
|
+
manager: { displayName: string; email: string };
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
const columns: (IColumnDef<Employee> | IColumnGroupDef<Employee>)[] = [
|
|
324
|
+
{
|
|
325
|
+
columnId: 'name',
|
|
326
|
+
name: 'Employee Name',
|
|
327
|
+
sortable: true,
|
|
328
|
+
required: true,
|
|
329
|
+
pinned: 'left',
|
|
330
|
+
minWidth: 150,
|
|
331
|
+
filterable: { type: 'text' },
|
|
332
|
+
editable: true,
|
|
333
|
+
cellEditor: 'text',
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
headerName: 'Details',
|
|
337
|
+
children: [
|
|
338
|
+
{
|
|
339
|
+
columnId: 'department',
|
|
340
|
+
name: 'Department',
|
|
341
|
+
filterable: {
|
|
342
|
+
type: 'multiSelect',
|
|
343
|
+
optionsSource: 'static',
|
|
344
|
+
options: ['Engineering', 'Marketing', 'Sales', 'HR'],
|
|
345
|
+
},
|
|
346
|
+
editable: true,
|
|
347
|
+
cellEditor: 'richSelect',
|
|
348
|
+
cellEditorParams: { values: ['Engineering', 'Marketing', 'Sales', 'HR'] },
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
columnId: 'salary',
|
|
352
|
+
name: 'Salary',
|
|
353
|
+
type: 'numeric',
|
|
354
|
+
valueFormatter: (value) => `$${Number(value).toLocaleString()}`,
|
|
355
|
+
valueParser: ({ newValue }) => Number(String(newValue).replace(/[$,]/g, '')),
|
|
356
|
+
editable: true,
|
|
357
|
+
cellStyle: (item) => ({
|
|
358
|
+
color: item.salary > 100000 ? 'green' : undefined,
|
|
359
|
+
}),
|
|
360
|
+
},
|
|
361
|
+
],
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
columnId: 'startDate',
|
|
365
|
+
name: 'Start Date',
|
|
366
|
+
defaultVisible: false,
|
|
367
|
+
valueFormatter: (value) => new Date(value as string).toLocaleDateString(),
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
columnId: 'manager',
|
|
371
|
+
name: 'Manager',
|
|
372
|
+
filterable: { type: 'people' },
|
|
373
|
+
valueGetter: (item) => item.manager,
|
|
374
|
+
renderCell: (item) => <span>{item.manager.displayName}</span>,
|
|
375
|
+
valueFormatter: (value) => (value as Employee['manager']).displayName,
|
|
376
|
+
editable: false,
|
|
377
|
+
},
|
|
378
|
+
];
|
|
379
|
+
```
|