@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.
Files changed (52) hide show
  1. package/README.md +68 -0
  2. package/bundled-docs/api/README.md +94 -0
  3. package/bundled-docs/api/column-def.mdx +379 -0
  4. package/bundled-docs/api/components-column-chooser.mdx +310 -0
  5. package/bundled-docs/api/components-column-header-filter.mdx +363 -0
  6. package/bundled-docs/api/components-datagrid-table.mdx +316 -0
  7. package/bundled-docs/api/components-pagination-controls.mdx +344 -0
  8. package/bundled-docs/api/components-sidebar.mdx +427 -0
  9. package/bundled-docs/api/components-status-bar.mdx +309 -0
  10. package/bundled-docs/api/grid-api.mdx +299 -0
  11. package/bundled-docs/api/js-api.mdx +198 -0
  12. package/bundled-docs/api/ogrid-props.mdx +244 -0
  13. package/bundled-docs/api/types.mdx +640 -0
  14. package/bundled-docs/features/cell-references.mdx +225 -0
  15. package/bundled-docs/features/column-chooser.mdx +279 -0
  16. package/bundled-docs/features/column-groups.mdx +290 -0
  17. package/bundled-docs/features/column-pinning.mdx +282 -0
  18. package/bundled-docs/features/column-reordering.mdx +359 -0
  19. package/bundled-docs/features/column-types.mdx +181 -0
  20. package/bundled-docs/features/context-menu.mdx +216 -0
  21. package/bundled-docs/features/csv-export.mdx +227 -0
  22. package/bundled-docs/features/editing.mdx +377 -0
  23. package/bundled-docs/features/filtering.mdx +330 -0
  24. package/bundled-docs/features/formulas.mdx +381 -0
  25. package/bundled-docs/features/grid-api.mdx +311 -0
  26. package/bundled-docs/features/keyboard-navigation.mdx +236 -0
  27. package/bundled-docs/features/pagination.mdx +245 -0
  28. package/bundled-docs/features/performance.mdx +433 -0
  29. package/bundled-docs/features/row-selection.mdx +256 -0
  30. package/bundled-docs/features/server-side-data.mdx +291 -0
  31. package/bundled-docs/features/sidebar.mdx +234 -0
  32. package/bundled-docs/features/sorting.mdx +241 -0
  33. package/bundled-docs/features/spreadsheet-selection.mdx +201 -0
  34. package/bundled-docs/features/status-bar.mdx +205 -0
  35. package/bundled-docs/features/toolbar.mdx +284 -0
  36. package/bundled-docs/features/virtual-scrolling.mdx +624 -0
  37. package/bundled-docs/getting-started/installation.mdx +216 -0
  38. package/bundled-docs/getting-started/overview.mdx +151 -0
  39. package/bundled-docs/getting-started/quick-start.mdx +425 -0
  40. package/bundled-docs/getting-started/vanilla-js.mdx +191 -0
  41. package/bundled-docs/guides/accessibility.mdx +550 -0
  42. package/bundled-docs/guides/controlled-vs-uncontrolled.mdx +153 -0
  43. package/bundled-docs/guides/custom-cell-editors.mdx +201 -0
  44. package/bundled-docs/guides/framework-showcase.mdx +200 -0
  45. package/bundled-docs/guides/mcp-live-testing.mdx +291 -0
  46. package/bundled-docs/guides/mcp.mdx +172 -0
  47. package/bundled-docs/guides/migration-from-ag-grid.mdx +223 -0
  48. package/bundled-docs/guides/theming.mdx +211 -0
  49. package/dist/esm/bridge-client.d.ts +87 -0
  50. package/dist/esm/bridge-client.js +162 -0
  51. package/dist/esm/index.js +1060 -0
  52. package/package.json +43 -0
@@ -0,0 +1,291 @@
1
+ ---
2
+ sidebar_position: 16
3
+ title: Server-Side Data
4
+ description: Fetch pages of data from a server with sorting, filtering, and people search
5
+ ---
6
+
7
+
8
+ # Server-Side Data
9
+
10
+ Pass a `dataSource` instead of a `data` array to delegate sorting, filtering, and pagination to your server.
11
+
12
+ ## Live Demo
13
+
14
+ <ServerSideDemo />
15
+
16
+ :::tip Try it in your framework
17
+ The demo above uses Radix UI for styling. To see this feature with your framework's design system (Fluent UI, Material UI, Vuetify, PrimeNG, etc.), click **"Open in online demo"** below the demo.
18
+ :::
19
+
20
+ ## Quick Example
21
+
22
+ <Tabs groupId="framework">
23
+ <TabItem value="react" label="React" default>
24
+
25
+ ```tsx
26
+
27
+ interface Employee {
28
+ id: number;
29
+ name: string;
30
+ department: string;
31
+ salary: number;
32
+ }
33
+
34
+ const dataSource: IDataSource<Employee> = {
35
+ async fetchPage(params: IFetchParams): Promise<IPageResult<Employee>> {
36
+ const query = new URLSearchParams({
37
+ page: String(params.page),
38
+ pageSize: String(params.pageSize),
39
+ ...(params.sort && {
40
+ sortField: params.sort.field,
41
+ sortDir: params.sort.direction,
42
+ }),
43
+ });
44
+ const res = await fetch(`/api/employees?${query}`);
45
+ return res.json(); // { items: Employee[], totalCount: number }
46
+ },
47
+ };
48
+
49
+ function App() {
50
+ return (
51
+ <OGrid
52
+ columns={columns}
53
+ dataSource={dataSource}
54
+ getRowId={(e) => e.id}
55
+ defaultPageSize={25}
56
+ />
57
+ );
58
+ }
59
+ ```
60
+
61
+ :::tip Switching UI libraries
62
+ The `OGrid` component has the same props across all React UI packages. To switch, just change the import:
63
+
64
+ - **Radix** (lightweight, default): `from '@alaarab/ogrid-react-radix'`
65
+ - **Fluent UI** (Microsoft 365 / SPFx): `from '@alaarab/ogrid-react-fluent'` — wrap in `<FluentProvider>`
66
+ - **Material UI** (MUI v7): `from '@alaarab/ogrid-react-material'` — wrap in `<ThemeProvider>`
67
+ :::
68
+
69
+ </TabItem>
70
+ <TabItem value="angular" label="Angular">
71
+
72
+ ```typescript
73
+
74
+ interface Employee {
75
+ id: number;
76
+ name: string;
77
+ department: string;
78
+ salary: number;
79
+ }
80
+
81
+ const dataSource: IDataSource<Employee> = {
82
+ async fetchPage(params: IFetchParams): Promise<IPageResult<Employee>> {
83
+ const query = new URLSearchParams({
84
+ page: String(params.page),
85
+ pageSize: String(params.pageSize),
86
+ ...(params.sort && {
87
+ sortField: params.sort.field,
88
+ sortDir: params.sort.direction,
89
+ }),
90
+ });
91
+ const res = await fetch(`/api/employees?${query}`);
92
+ return res.json();
93
+ },
94
+ };
95
+
96
+ @Component({
97
+ standalone: true,
98
+ imports: [OGridComponent],
99
+ template: `<ogrid [props]="gridProps" />`
100
+ })
101
+ export class GridComponent {
102
+ gridProps = {
103
+ columns: columns,
104
+ dataSource,
105
+ getRowId: (e: Employee) => e.id,
106
+ defaultPageSize: 25,
107
+ };
108
+ }
109
+ ```
110
+
111
+ :::tip Switching UI libraries
112
+ Same component API across Angular packages. To switch, just change the import:
113
+
114
+ - **Radix (CDK)**: `from '@alaarab/ogrid-angular-radix'` *(default, lightweight)*
115
+ - **Angular Material**: `from '@alaarab/ogrid-angular-material'`
116
+ - **PrimeNG**: `from '@alaarab/ogrid-angular-primeng'`
117
+
118
+ All components are standalone — no NgModule required.
119
+ :::
120
+
121
+ </TabItem>
122
+ <TabItem value="vue" label="Vue">
123
+
124
+ ```vue
125
+ <script setup lang="ts">
126
+
127
+ interface Employee {
128
+ id: number;
129
+ name: string;
130
+ department: string;
131
+ salary: number;
132
+ }
133
+
134
+ const dataSource: IDataSource<Employee> = {
135
+ async fetchPage(params: IFetchParams): Promise<IPageResult<Employee>> {
136
+ const query = new URLSearchParams({
137
+ page: String(params.page),
138
+ pageSize: String(params.pageSize),
139
+ ...(params.sort && {
140
+ sortField: params.sort.field,
141
+ sortDir: params.sort.direction,
142
+ }),
143
+ });
144
+ const res = await fetch(`/api/employees?${query}`);
145
+ return res.json();
146
+ },
147
+ };
148
+
149
+ const gridProps = {
150
+ columns,
151
+ dataSource,
152
+ getRowId: (e: Employee) => e.id,
153
+ defaultPageSize: 25,
154
+ };
155
+ </script>
156
+
157
+ <template>
158
+ <OGrid :gridProps="gridProps" />
159
+ </template>
160
+ ```
161
+
162
+ :::tip Switching UI libraries
163
+ Same component API across Vue packages. To switch, just change the import:
164
+
165
+ - **Radix (Headless UI)**: `from '@alaarab/ogrid-vue-radix'` *(default, lightweight)*
166
+ - **Vuetify**: `from '@alaarab/ogrid-vue-vuetify'` — wrap in `<v-app>` for theming
167
+ - **PrimeVue**: `from '@alaarab/ogrid-vue-primevue'`
168
+ :::
169
+
170
+ </TabItem>
171
+ <TabItem value="js" label="Vanilla JS">
172
+
173
+ ```js
174
+
175
+ const grid = new OGrid(document.getElementById('grid'), {
176
+ columns: columns,
177
+ dataSource: {
178
+ async fetchPage({ page, pageSize, sort, filters }) {
179
+ const query = new URLSearchParams({
180
+ page: String(page),
181
+ pageSize: String(pageSize),
182
+ ...(sort && {
183
+ sortField: sort.field,
184
+ sortDir: sort.direction,
185
+ }),
186
+ });
187
+ const res = await fetch(`/api/employees?${query}`);
188
+ return res.json(); // { items: Employee[], totalCount: number }
189
+ },
190
+ },
191
+ getRowId: (e) => e.id,
192
+ pageSize: 25,
193
+ });
194
+ ```
195
+
196
+ </TabItem>
197
+ </Tabs>
198
+
199
+ The grid fetches the first page on mount and re-fetches whenever page, sort, or filters change.
200
+
201
+ ## IDataSource&lt;T&gt; Reference
202
+
203
+ ```typescript
204
+ interface IDataSource<T> {
205
+ fetchPage(params: IFetchParams): Promise<IPageResult<T>>;
206
+ fetchFilterOptions?(field: string): Promise<string[]>;
207
+ searchPeople?(query: string): Promise<UserLike[]>;
208
+ getUserByEmail?(email: string): Promise<UserLike | undefined>;
209
+ }
210
+ ```
211
+
212
+ | Method | Required | Description |
213
+ |--------|----------|-------------|
214
+ | `fetchPage` | Yes | Fetches a page of data. Called on page/sort/filter changes. |
215
+ | `fetchFilterOptions` | No | Returns options for `multiSelect` filters with `optionsSource: 'api'`. |
216
+ | `searchPeople` | No | Searches people for `people`-type column filters. |
217
+ | `getUserByEmail` | No | Resolves a user by email (for restoring saved people filters). |
218
+
219
+ ### IFetchParams
220
+
221
+ ```typescript
222
+ interface IFetchParams {
223
+ page: number; // 1-indexed
224
+ pageSize: number;
225
+ sort?: { field: string; direction: 'asc' | 'desc' };
226
+ filters: IFilters; // See Types reference for FilterValue shapes
227
+ }
228
+ ```
229
+
230
+ ### IPageResult&lt;T&gt;
231
+
232
+ ```typescript
233
+ interface IPageResult<T> {
234
+ items: T[];
235
+ totalCount: number; // drives pagination controls
236
+ }
237
+ ```
238
+
239
+ ## Filter Options & People Search
240
+
241
+ ```tsx
242
+ const dataSource: IDataSource<Employee> = {
243
+ async fetchPage(params) { /* ... */ },
244
+
245
+ async fetchFilterOptions(field: string): Promise<string[]> {
246
+ const res = await fetch(`/api/employees/filter-options/${field}`);
247
+ return res.json(); // ['Engineering', 'Marketing', 'Sales']
248
+ },
249
+
250
+ async searchPeople(query: string): Promise<UserLike[]> {
251
+ const res = await fetch(`/api/people/search?q=${query}`);
252
+ return res.json();
253
+ },
254
+
255
+ async getUserByEmail(email: string): Promise<UserLike | undefined> {
256
+ const res = await fetch(`/api/people/${email}`);
257
+ if (!res.ok) return undefined;
258
+ return res.json();
259
+ },
260
+ };
261
+ ```
262
+
263
+ ## Error Handling & Loading
264
+
265
+ ```tsx
266
+ <OGrid
267
+ columns={columns}
268
+ dataSource={dataSource}
269
+ getRowId={(e) => e.id}
270
+ onError={(error) => {
271
+ console.error('Grid fetch failed:', error);
272
+ showToast('Failed to load data.');
273
+ }}
274
+ />
275
+ ```
276
+
277
+ The grid manages loading state automatically. You can also control it via `gridRef.current?.setLoading(true)`.
278
+
279
+ ## Client-Side vs. Server-Side
280
+
281
+ | | Client-side (`data`) | Server-side (`dataSource`) |
282
+ |---|---|---|
283
+ | Data location | All rows in memory | Fetched per page |
284
+ | Sorting / Filtering | In-memory by the grid | Your server handles it |
285
+ | Best for | < 10,000 rows | Large datasets, real-time data |
286
+
287
+ ## Related
288
+
289
+ - [Filtering](./filtering) -- filter types and configuration
290
+ - [Grid API](../api/grid-api) -- `setFilterModel()` for programmatic filtering
291
+ - [Types](../api/types) -- `IFilters`, `FilterValue`, `UserLike` shapes
@@ -0,0 +1,234 @@
1
+ ---
2
+ sidebar_position: 15.5
3
+ title: Side Bar
4
+ description: Collapsible side panel with Columns and Filters panels for managing column visibility and filtering.
5
+ ---
6
+
7
+
8
+ # Side Bar
9
+
10
+ The Side Bar adds a collapsible panel alongside the grid with two built-in panels: **Columns** (toggle column visibility with Select All / Clear All) and **Filters** (inline text, multi-select, and date filters). Click the tab icons to open or close panels.
11
+
12
+ ## Live Demo
13
+
14
+ <SideBarDemo />
15
+
16
+ :::tip Try it in your framework
17
+ The demo above uses Radix UI for styling. To see this feature with your framework's design system (Fluent UI, Material UI, Vuetify, PrimeNG, etc.), click **"Open in online demo"** below the demo.
18
+ :::
19
+
20
+ <Tabs groupId="framework">
21
+ <TabItem value="react" label="React" default>
22
+
23
+ ```tsx
24
+
25
+ <OGrid
26
+ columns={columns}
27
+ data={items}
28
+ getRowId={(item) => item.id}
29
+ sideBar
30
+ columnChooser="sidebar"
31
+ pagination
32
+ />
33
+ ```
34
+
35
+ :::tip Switching UI libraries
36
+ The `OGrid` component has the same props across all React UI packages. To switch, just change the import:
37
+
38
+ - **Radix** (lightweight, default): `from '@alaarab/ogrid-react-radix'`
39
+ - **Fluent UI** (Microsoft 365 / SPFx): `from '@alaarab/ogrid-react-fluent'` — wrap in `<FluentProvider>`
40
+ - **Material UI** (MUI v7): `from '@alaarab/ogrid-react-material'` — wrap in `<ThemeProvider>`
41
+ :::
42
+
43
+ </TabItem>
44
+ <TabItem value="angular" label="Angular">
45
+
46
+ ```typescript
47
+
48
+ @Component({
49
+ standalone: true,
50
+ imports: [OGridComponent],
51
+ template: `<ogrid [props]="gridProps" />`
52
+ })
53
+ export class GridComponent {
54
+ gridProps = {
55
+ columns: columns,
56
+ data: items,
57
+ getRowId: (item: Item) => item.id,
58
+ sideBar: true,
59
+ columnChooser: 'sidebar' as const,
60
+ pagination: true,
61
+ };
62
+ }
63
+ ```
64
+
65
+ :::tip Switching UI libraries
66
+ Same component API across Angular packages. To switch, just change the import:
67
+
68
+ - **Radix (CDK)**: `from '@alaarab/ogrid-angular-radix'` *(default, lightweight)*
69
+ - **Angular Material**: `from '@alaarab/ogrid-angular-material'`
70
+ - **PrimeNG**: `from '@alaarab/ogrid-angular-primeng'`
71
+
72
+ All components are standalone — no NgModule required.
73
+ :::
74
+
75
+ </TabItem>
76
+ <TabItem value="vue" label="Vue">
77
+
78
+ ```vue
79
+ <script setup lang="ts">
80
+
81
+ const gridProps = {
82
+ columns,
83
+ data: items,
84
+ getRowId: (item) => item.id,
85
+ sideBar: true,
86
+ columnChooser: 'sidebar' as const,
87
+ pagination: true,
88
+ };
89
+ </script>
90
+
91
+ <template>
92
+ <OGrid :gridProps="gridProps" />
93
+ </template>
94
+ ```
95
+
96
+ :::tip Switching UI libraries
97
+ Same component API across Vue packages. To switch, just change the import:
98
+
99
+ - **Radix (Headless UI)**: `from '@alaarab/ogrid-vue-radix'` *(default, lightweight)*
100
+ - **Vuetify**: `from '@alaarab/ogrid-vue-vuetify'` — wrap in `<v-app>` for theming
101
+ - **PrimeVue**: `from '@alaarab/ogrid-vue-primevue'`
102
+ :::
103
+
104
+ </TabItem>
105
+ <TabItem value="js" label="Vanilla JS">
106
+
107
+ ```js
108
+
109
+ const grid = new OGrid(document.getElementById('grid'), {
110
+ columns: columns,
111
+ data: items,
112
+ getRowId: (item) => item.id,
113
+ sideBar: true,
114
+ columnChooser: 'sidebar',
115
+ pagination: true,
116
+ });
117
+ ```
118
+
119
+ </TabItem>
120
+ </Tabs>
121
+
122
+ Set `sideBar` to `true` to enable both panels with default settings. Set `columnChooser="sidebar"` to move the column chooser from the toolbar into the sidebar's Columns panel.
123
+
124
+ ## Panels
125
+
126
+ ### Columns Panel
127
+
128
+ The Columns panel lists every column with a checkbox. Users can:
129
+
130
+ - Toggle individual columns on or off
131
+ - **Select All** to show every column
132
+ - **Clear All** to hide all non-required columns
133
+
134
+ Columns with `required: true` cannot be hidden — their checkboxes are disabled.
135
+
136
+ ### Filters Panel
137
+
138
+ The Filters panel shows inline filter controls for every filterable column:
139
+
140
+ | Column filter type | Sidebar control |
141
+ |---|---|
142
+ | `text` | Text input |
143
+ | `multiSelect` | Checkbox list of options |
144
+ | `date` | From / To date inputs |
145
+
146
+ Filters applied in the sidebar work the same as column header filters — they share state.
147
+
148
+ ## Configuration
149
+
150
+ Pass an `ISideBarDef` object instead of `true` to customize panels, position, and default state.
151
+
152
+ ### Left Position
153
+
154
+ <SideBarLeftDemo />
155
+
156
+ ```tsx
157
+
158
+ const sideBarDef: ISideBarDef = {
159
+ position: 'left',
160
+ defaultPanel: 'filters',
161
+ };
162
+
163
+ <OGrid
164
+ columns={columns}
165
+ data={items}
166
+ getRowId={(item) => item.id}
167
+ sideBar={sideBarDef}
168
+ columnChooser="sidebar"
169
+ />
170
+ ```
171
+
172
+ ### Columns Panel Only
173
+
174
+ <SideBarColumnsOnlyDemo />
175
+
176
+ ```tsx
177
+ const sideBarDef: ISideBarDef = {
178
+ panels: ['columns'],
179
+ defaultPanel: 'columns',
180
+ };
181
+
182
+ <OGrid
183
+ columns={columns}
184
+ data={items}
185
+ getRowId={(item) => item.id}
186
+ sideBar={sideBarDef}
187
+ columnChooser="sidebar"
188
+ />
189
+ ```
190
+
191
+ ### Filters Panel Only
192
+
193
+ ```tsx
194
+ const sideBarDef: ISideBarDef = {
195
+ panels: ['filters'],
196
+ };
197
+
198
+ <OGrid
199
+ columns={columns}
200
+ data={items}
201
+ getRowId={(item) => item.id}
202
+ sideBar={sideBarDef}
203
+ />
204
+ ```
205
+
206
+ ## Props
207
+
208
+ ### `sideBar` (on `IOGridProps`)
209
+
210
+ | Value | Behavior |
211
+ |-------|----------|
212
+ | `false` / omitted | No side bar |
213
+ | `true` | Both panels, right position, collapsed on mount |
214
+ | `ISideBarDef` | Full configuration (see below) |
215
+
216
+ ### `ISideBarDef`
217
+
218
+ | Field | Type | Default | Description |
219
+ |-------|------|---------|-------------|
220
+ | `panels` | `SideBarPanelId[]` | `['columns', 'filters']` | Which panels to include. |
221
+ | `defaultPanel` | `SideBarPanelId` | -- | Panel to open automatically on mount. |
222
+ | `position` | `'left' \| 'right'` | `'right'` | Which side of the grid the bar appears on. |
223
+
224
+ ### `SideBarPanelId`
225
+
226
+ ```ts
227
+ type SideBarPanelId = 'columns' | 'filters';
228
+ ```
229
+
230
+ ## Related
231
+
232
+ - [Column Chooser](./column-chooser) -- standalone column visibility dropdown
233
+ - [Toolbar & Layout](./toolbar) -- the container that wraps sidebar + grid
234
+ - [Filtering](./filtering) -- column header filters (shared state with sidebar)