@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
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 14.5
|
|
3
|
+
title: Toolbar & Layout
|
|
4
|
+
description: Unified bordered container with configurable toolbar strip, sidebar, and column chooser placement.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
# Toolbar & Layout
|
|
9
|
+
|
|
10
|
+
OGrid wraps your grid in a **single bordered container** with three sections: a toolbar strip, the grid area, and a footer. Every section is optional — the container adapts to what you enable.
|
|
11
|
+
|
|
12
|
+
## Layout Anatomy
|
|
13
|
+
|
|
14
|
+
<LayoutDiagram />
|
|
15
|
+
|
|
16
|
+
Every combination is valid — you can use just the grid, add a toolbar, add pagination, enable the sidebar, or use all of them together. The bordered container handles spacing and borders automatically.
|
|
17
|
+
|
|
18
|
+
## Default Layout
|
|
19
|
+
|
|
20
|
+
With no extra props, OGrid renders a toolbar strip containing only the column chooser button on the right, plus the grid. Click the columns button to toggle column visibility.
|
|
21
|
+
|
|
22
|
+
<ToolbarDefaultDemo />
|
|
23
|
+
|
|
24
|
+
:::tip Try it in your framework
|
|
25
|
+
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.
|
|
26
|
+
:::
|
|
27
|
+
|
|
28
|
+
<Tabs groupId="framework">
|
|
29
|
+
<TabItem value="react" label="React" default>
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
|
|
33
|
+
<OGrid
|
|
34
|
+
columns={columns}
|
|
35
|
+
data={items}
|
|
36
|
+
getRowId={(item) => item.id}
|
|
37
|
+
columnChooser="toolbar"
|
|
38
|
+
pagination
|
|
39
|
+
/>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
:::tip Switching UI libraries
|
|
43
|
+
The `OGrid` component has the same props across all React UI packages. To switch, just change the import:
|
|
44
|
+
|
|
45
|
+
- **Radix** (lightweight, default): `from '@alaarab/ogrid-react-radix'`
|
|
46
|
+
- **Fluent UI** (Microsoft 365 / SPFx): `from '@alaarab/ogrid-react-fluent'` — wrap in `<FluentProvider>`
|
|
47
|
+
- **Material UI** (MUI v7): `from '@alaarab/ogrid-react-material'` — wrap in `<ThemeProvider>`
|
|
48
|
+
:::
|
|
49
|
+
|
|
50
|
+
</TabItem>
|
|
51
|
+
<TabItem value="angular" label="Angular">
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
|
|
55
|
+
@Component({
|
|
56
|
+
standalone: true,
|
|
57
|
+
imports: [OGridComponent],
|
|
58
|
+
template: `<ogrid [props]="gridProps" />`
|
|
59
|
+
})
|
|
60
|
+
export class GridComponent {
|
|
61
|
+
gridProps = {
|
|
62
|
+
columns: columns,
|
|
63
|
+
data: items,
|
|
64
|
+
getRowId: (item: Item) => item.id,
|
|
65
|
+
columnChooser: 'toolbar' as const,
|
|
66
|
+
pagination: true,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
:::tip Switching UI libraries
|
|
72
|
+
Same component API across Angular packages. To switch, just change the import:
|
|
73
|
+
|
|
74
|
+
- **Radix (CDK)**: `from '@alaarab/ogrid-angular-radix'` *(default, lightweight)*
|
|
75
|
+
- **Angular Material**: `from '@alaarab/ogrid-angular-material'`
|
|
76
|
+
- **PrimeNG**: `from '@alaarab/ogrid-angular-primeng'`
|
|
77
|
+
|
|
78
|
+
All components are standalone — no NgModule required.
|
|
79
|
+
:::
|
|
80
|
+
|
|
81
|
+
</TabItem>
|
|
82
|
+
<TabItem value="vue" label="Vue">
|
|
83
|
+
|
|
84
|
+
```vue
|
|
85
|
+
<script setup lang="ts">
|
|
86
|
+
|
|
87
|
+
const gridProps = {
|
|
88
|
+
columns,
|
|
89
|
+
data: items,
|
|
90
|
+
getRowId: (item) => item.id,
|
|
91
|
+
columnChooser: 'toolbar' as const,
|
|
92
|
+
pagination: true,
|
|
93
|
+
};
|
|
94
|
+
</script>
|
|
95
|
+
|
|
96
|
+
<template>
|
|
97
|
+
<OGrid :gridProps="gridProps" />
|
|
98
|
+
</template>
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
:::tip Switching UI libraries
|
|
102
|
+
Same component API across Vue packages. To switch, just change the import:
|
|
103
|
+
|
|
104
|
+
- **Radix (Headless UI)**: `from '@alaarab/ogrid-vue-radix'` *(default, lightweight)*
|
|
105
|
+
- **Vuetify**: `from '@alaarab/ogrid-vue-vuetify'` — wrap in `<v-app>` for theming
|
|
106
|
+
- **PrimeVue**: `from '@alaarab/ogrid-vue-primevue'`
|
|
107
|
+
:::
|
|
108
|
+
|
|
109
|
+
</TabItem>
|
|
110
|
+
<TabItem value="js" label="Vanilla JS">
|
|
111
|
+
|
|
112
|
+
```js
|
|
113
|
+
|
|
114
|
+
const grid = new OGrid(document.getElementById('grid'), {
|
|
115
|
+
columns: columns,
|
|
116
|
+
data: items,
|
|
117
|
+
getRowId: (item) => item.id,
|
|
118
|
+
columnChooser: true,
|
|
119
|
+
pagination: true,
|
|
120
|
+
});
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
</TabItem>
|
|
124
|
+
</Tabs>
|
|
125
|
+
|
|
126
|
+
## Custom Toolbar Content
|
|
127
|
+
|
|
128
|
+
The `toolbar` prop places your content on the **left** side of the toolbar strip. The column chooser stays on the **right**. Use this for action buttons, search inputs, status text, or anything else.
|
|
129
|
+
|
|
130
|
+
<ToolbarCustomDemo />
|
|
131
|
+
|
|
132
|
+
```tsx
|
|
133
|
+
<OGrid
|
|
134
|
+
columns={columns}
|
|
135
|
+
data={items}
|
|
136
|
+
getRowId={(item) => item.id}
|
|
137
|
+
toolbar={
|
|
138
|
+
<div style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
|
|
139
|
+
<button onClick={handleExport}>Export CSV</button>
|
|
140
|
+
<button onClick={handleSelectAll}>Select All</button>
|
|
141
|
+
<span>{data.length} rows</span>
|
|
142
|
+
</div>
|
|
143
|
+
}
|
|
144
|
+
columnChooser="toolbar"
|
|
145
|
+
pagination
|
|
146
|
+
/>
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Secondary Toolbar Row
|
|
150
|
+
|
|
151
|
+
The `toolbarBelow` prop renders a **secondary row** below the primary toolbar strip. Use it for active filter chips, breadcrumbs, search bars, or any contextual content that should sit between the toolbar and the grid.
|
|
152
|
+
|
|
153
|
+
<ToolbarBelowDemo />
|
|
154
|
+
|
|
155
|
+
```tsx
|
|
156
|
+
<OGrid
|
|
157
|
+
columns={columns}
|
|
158
|
+
data={items}
|
|
159
|
+
getRowId={(item) => item.id}
|
|
160
|
+
toolbar={
|
|
161
|
+
<div style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
|
|
162
|
+
<button onClick={handleExport}>Export CSV</button>
|
|
163
|
+
<span>{data.length} rows</span>
|
|
164
|
+
</div>
|
|
165
|
+
}
|
|
166
|
+
toolbarBelow={
|
|
167
|
+
<div style={{ display: 'flex', gap: 6, flexWrap: 'wrap' }}>
|
|
168
|
+
<span style={{ padding: '2px 8px', background: '#e0e0e0', borderRadius: 12, fontSize: 12 }}>
|
|
169
|
+
Department: Engineering ✕
|
|
170
|
+
</span>
|
|
171
|
+
<span style={{ padding: '2px 8px', background: '#e0e0e0', borderRadius: 12, fontSize: 12 }}>
|
|
172
|
+
Status: Active ✕
|
|
173
|
+
</span>
|
|
174
|
+
</div>
|
|
175
|
+
}
|
|
176
|
+
columnChooser="toolbar"
|
|
177
|
+
pagination
|
|
178
|
+
/>
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
:::tip
|
|
182
|
+
The secondary toolbar row shares the same background and border styling as the primary toolbar. It only renders when `toolbarBelow` is provided — no empty space when omitted.
|
|
183
|
+
:::
|
|
184
|
+
|
|
185
|
+
## Column Chooser Placement
|
|
186
|
+
|
|
187
|
+
The `columnChooser` prop controls where the column visibility control appears:
|
|
188
|
+
|
|
189
|
+
| Value | Behavior |
|
|
190
|
+
|-------|----------|
|
|
191
|
+
| `true` or `'toolbar'` | Column chooser button in the toolbar strip (default) |
|
|
192
|
+
| `'sidebar'` | Column chooser moves to the sidebar's Columns panel |
|
|
193
|
+
| `false` | Hidden entirely — columns are locked |
|
|
194
|
+
|
|
195
|
+
### Sidebar Mode
|
|
196
|
+
|
|
197
|
+
When `columnChooser="sidebar"`, the column chooser button is removed from the toolbar. Instead, users toggle column visibility from the sidebar's Columns panel. This is useful when you have many columns and want a dedicated panel for managing them.
|
|
198
|
+
|
|
199
|
+
<ToolbarSidebarDemo />
|
|
200
|
+
|
|
201
|
+
```tsx
|
|
202
|
+
<OGrid
|
|
203
|
+
columns={columns}
|
|
204
|
+
data={items}
|
|
205
|
+
getRowId={(item) => item.id}
|
|
206
|
+
columnChooser="sidebar"
|
|
207
|
+
sideBar
|
|
208
|
+
pagination
|
|
209
|
+
/>
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
:::tip
|
|
213
|
+
The sidebar also includes a **Filters** panel with inline filter controls. Click the filter icon tab to switch panels.
|
|
214
|
+
:::
|
|
215
|
+
|
|
216
|
+
### Hidden
|
|
217
|
+
|
|
218
|
+
Set `columnChooser={false}` when you want to lock the visible columns and prevent users from changing them.
|
|
219
|
+
|
|
220
|
+
```tsx
|
|
221
|
+
<OGrid
|
|
222
|
+
columns={columns}
|
|
223
|
+
data={items}
|
|
224
|
+
getRowId={(item) => item.id}
|
|
225
|
+
columnChooser={false}
|
|
226
|
+
/>
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## Full Layout
|
|
230
|
+
|
|
231
|
+
Here is every layout feature enabled at once — toolbar with custom buttons, column chooser, sidebar, cell selection with status bar aggregations, and pagination:
|
|
232
|
+
|
|
233
|
+
<ToolbarFullDemo />
|
|
234
|
+
|
|
235
|
+
```tsx
|
|
236
|
+
<OGrid
|
|
237
|
+
ref={gridRef}
|
|
238
|
+
columns={columns}
|
|
239
|
+
data={items}
|
|
240
|
+
getRowId={(item) => item.id}
|
|
241
|
+
columnChooser="toolbar"
|
|
242
|
+
sideBar
|
|
243
|
+
statusBar
|
|
244
|
+
cellSelection
|
|
245
|
+
pagination
|
|
246
|
+
toolbar={
|
|
247
|
+
<div style={{ display: 'flex', gap: 8 }}>
|
|
248
|
+
<button onClick={() => gridRef.current?.deselectAll()}>
|
|
249
|
+
Clear Selection
|
|
250
|
+
</button>
|
|
251
|
+
</div>
|
|
252
|
+
}
|
|
253
|
+
/>
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
## Headings and Titles
|
|
257
|
+
|
|
258
|
+
The `title` prop is **deprecated**. Render headings outside the `<OGrid>` component for full control over styling:
|
|
259
|
+
|
|
260
|
+
```tsx
|
|
261
|
+
<div>
|
|
262
|
+
<h1>Projects Dashboard</h1>
|
|
263
|
+
<p>Manage all active projects below.</p>
|
|
264
|
+
<OGrid columns={columns} data={projects} getRowId={(p) => p.id} />
|
|
265
|
+
</div>
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
## Props
|
|
269
|
+
|
|
270
|
+
| Prop | Type | Default | Description |
|
|
271
|
+
|------|------|---------|-------------|
|
|
272
|
+
| `toolbar` | `ReactNode` | -- | Custom content in the left side of the toolbar strip. |
|
|
273
|
+
| `toolbarBelow` | `ReactNode` | -- | Secondary toolbar row below the primary toolbar (e.g. filter chips, breadcrumbs). |
|
|
274
|
+
| `columnChooser` | `boolean \| 'toolbar' \| 'sidebar'` | `true` | Where to place the column chooser. `true`/`'toolbar'` = toolbar, `'sidebar'` = sidebar panel only, `false` = hidden. |
|
|
275
|
+
| `sideBar` | `boolean \| ISideBarDef` | `false` | Enable sidebar panels. Required for `columnChooser="sidebar"`. |
|
|
276
|
+
| `statusBar` | `boolean` | `false` | Show status bar below the grid with row counts and aggregations. |
|
|
277
|
+
| `pagination` | `boolean \| IPaginationProps` | `false` | Show pagination in the footer strip. |
|
|
278
|
+
| `cellSelection` | `boolean` | `true` | Enable cell range selection (needed for status bar aggregations). |
|
|
279
|
+
|
|
280
|
+
## Related
|
|
281
|
+
|
|
282
|
+
- [Column Chooser](./column-chooser) -- toggle column visibility
|
|
283
|
+
- [Status Bar](./status-bar) -- row counts and aggregations
|
|
284
|
+
- [Pagination](./pagination) -- paginate data rows
|