Skip to content

Commit 3742699

Browse files
Copilothotlong
andcommitted
docs(plugin-aggrid): Add interactive examples for new features
- Add Inline Editing example with editable cells - Add CSV Export example with export button - Add Status Bar example with aggregations - Add Context Menu example with right-click actions - Add Column Configuration example with resizable columns - Add Complete Example combining all enterprise features - Update Features list to include new capabilities - Expand Schema API documentation with all new properties - Add usage examples for editing, export, status bar, and context menu Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 50948cb commit 3742699

1 file changed

Lines changed: 323 additions & 8 deletions

File tree

content/docs/plugins/plugin-aggrid.mdx

Lines changed: 323 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,152 @@ Note: `ag-grid-community` and `ag-grid-react` are peer dependencies and must be
176176
description="Enable checkbox selection for multiple rows"
177177
/>
178178

179-
### Advanced Features
179+
### Inline Editing
180+
181+
<InteractiveDemo
182+
schema={{
183+
type: "aggrid",
184+
rowData: [
185+
{ id: 1, product: "Laptop", price: 1299, quantity: 5, inStock: true },
186+
{ id: 2, product: "Mouse", price: 49, quantity: 15, inStock: true },
187+
{ id: 3, product: "Keyboard", price: 89, quantity: 8, inStock: true },
188+
{ id: 4, product: "Monitor", price: 499, quantity: 3, inStock: false },
189+
{ id: 5, product: "Webcam", price: 129, quantity: 12, inStock: true }
190+
],
191+
columnDefs: [
192+
{ field: "id", headerName: "ID", sortable: true },
193+
{ field: "product", headerName: "Product", sortable: true, filter: true, editable: true },
194+
{ field: "price", headerName: "Price ($)", sortable: true, filter: "number", editable: true },
195+
{ field: "quantity", headerName: "Quantity", sortable: true, filter: "number", editable: true },
196+
{ field: "inStock", headerName: "In Stock", sortable: true, editable: true }
197+
],
198+
editable: true,
199+
singleClickEdit: false,
200+
height: 350
201+
}}
202+
title="Inline Editing"
203+
description="Double-click any cell to edit. Changes are reflected immediately."
204+
/>
205+
206+
### CSV Export
207+
208+
<InteractiveDemo
209+
schema={{
210+
type: "aggrid",
211+
rowData: [
212+
{ orderID: "ORD-001", customer: "Acme Corp", amount: 15750, date: "2024-01-15", status: "Delivered" },
213+
{ orderID: "ORD-002", customer: "TechStart Inc", amount: 8500, date: "2024-01-18", status: "Shipped" },
214+
{ orderID: "ORD-003", customer: "Global Solutions", amount: 22300, date: "2024-01-20", status: "Processing" },
215+
{ orderID: "ORD-004", customer: "Innovation Labs", amount: 12100, date: "2024-01-22", status: "Delivered" },
216+
{ orderID: "ORD-005", customer: "Future Systems", amount: 9800, date: "2024-01-25", status: "Shipped" }
217+
],
218+
columnDefs: [
219+
{ field: "orderID", headerName: "Order ID", sortable: true, filter: true },
220+
{ field: "customer", headerName: "Customer", sortable: true, filter: true },
221+
{ field: "amount", headerName: "Amount", sortable: true, filter: "number" },
222+
{ field: "date", headerName: "Date", sortable: true, filter: "date" },
223+
{ field: "status", headerName: "Status", sortable: true, filter: true }
224+
],
225+
exportConfig: {
226+
enabled: true,
227+
fileName: "orders.csv"
228+
},
229+
height: 350
230+
}}
231+
title="CSV Export"
232+
description="Click the Export CSV button to download the grid data"
233+
/>
234+
235+
### Status Bar with Aggregations
236+
237+
<InteractiveDemo
238+
schema={{
239+
type: "aggrid",
240+
rowData: [
241+
{ item: "Laptop", category: "Electronics", price: 1299, quantity: 5 },
242+
{ item: "Desk", category: "Furniture", price: 599, quantity: 3 },
243+
{ item: "Chair", category: "Furniture", price: 299, quantity: 8 },
244+
{ item: "Monitor", category: "Electronics", price: 499, quantity: 6 },
245+
{ item: "Keyboard", category: "Electronics", price: 89, quantity: 12 },
246+
{ item: "Mouse", category: "Electronics", price: 49, quantity: 15 }
247+
],
248+
columnDefs: [
249+
{ field: "item", headerName: "Item", sortable: true, filter: true },
250+
{ field: "category", headerName: "Category", sortable: true, filter: true },
251+
{ field: "price", headerName: "Price ($)", sortable: true, filter: "number", aggFunc: "sum" },
252+
{ field: "quantity", headerName: "Quantity", sortable: true, filter: "number", aggFunc: "sum" }
253+
],
254+
statusBar: {
255+
enabled: true,
256+
aggregations: ["count", "sum", "avg"]
257+
},
258+
rowSelection: "multiple",
259+
height: 400
260+
}}
261+
title="Status Bar"
262+
description="Status bar shows aggregations at the bottom. Select rows to see aggregate values."
263+
/>
264+
265+
### Context Menu
266+
267+
<InteractiveDemo
268+
schema={{
269+
type: "aggrid",
270+
rowData: [
271+
{ id: 1, name: "Alice Johnson", role: "Engineer", salary: 95000 },
272+
{ id: 2, name: "Bob Smith", role: "Designer", salary: 72000 },
273+
{ id: 3, name: "Carol Davis", role: "Manager", salary: 88000 },
274+
{ id: 4, name: "David Wilson", role: "Engineer", salary: 102000 },
275+
{ id: 5, name: "Eve Brown", role: "Designer", salary: 75000 }
276+
],
277+
columnDefs: [
278+
{ field: "id", headerName: "ID", sortable: true },
279+
{ field: "name", headerName: "Name", sortable: true, filter: true },
280+
{ field: "role", headerName: "Role", sortable: true, filter: true },
281+
{ field: "salary", headerName: "Salary", sortable: true, filter: "number" }
282+
],
283+
contextMenu: {
284+
enabled: true,
285+
items: ["copy", "copyWithHeaders", "separator", "export", "autoSizeAll"]
286+
},
287+
height: 350
288+
}}
289+
title="Context Menu"
290+
description="Right-click on the grid to access context menu options"
291+
/>
292+
293+
### Column Configuration
294+
295+
<InteractiveDemo
296+
schema={{
297+
type: "aggrid",
298+
rowData: [
299+
{ code: "AAPL", company: "Apple Inc.", price: 178.25, change: 2.45, volume: 45678900 },
300+
{ code: "GOOGL", company: "Alphabet Inc.", price: 142.18, change: -1.23, volume: 23456700 },
301+
{ code: "MSFT", company: "Microsoft Corp.", price: 415.63, change: 5.89, volume: 34567800 },
302+
{ code: "AMZN", company: "Amazon.com Inc.", price: 175.32, change: -0.87, volume: 56789000 },
303+
{ code: "TSLA", company: "Tesla Inc.", price: 238.45, change: 12.67, volume: 78901200 }
304+
],
305+
columnDefs: [
306+
{ field: "code", headerName: "Code" },
307+
{ field: "company", headerName: "Company" },
308+
{ field: "price", headerName: "Price ($)", filter: "number" },
309+
{ field: "change", headerName: "Change", filter: "number" },
310+
{ field: "volume", headerName: "Volume", filter: "number" }
311+
],
312+
columnConfig: {
313+
resizable: true,
314+
sortable: true,
315+
filterable: true
316+
},
317+
enableRangeSelection: true,
318+
height: 350
319+
}}
320+
title="Column Configuration"
321+
description="All columns are resizable, sortable, and filterable. Drag column borders to resize."
322+
/>
323+
324+
### Complete Example with All Features
180325

181326
<InteractiveDemo
182327
schema={{
@@ -192,19 +337,36 @@ Note: `ag-grid-community` and `ag-grid-react` are peer dependencies and must be
192337
{ orderID: "ORD-008", customer: "Digital Ventures", amount: 14200, date: "2024-02-01", status: "Shipped" }
193338
],
194339
columnDefs: [
195-
{ field: "orderID", headerName: "Order ID", sortable: true, filter: true, pinned: "left" },
196-
{ field: "customer", headerName: "Customer", sortable: true, filter: true },
197-
{ field: "amount", headerName: "Amount", sortable: true, filter: "number" },
340+
{ field: "orderID", headerName: "Order ID", sortable: true, filter: true, pinned: "left", checkboxSelection: true },
341+
{ field: "customer", headerName: "Customer", sortable: true, filter: true, editable: true },
342+
{ field: "amount", headerName: "Amount", sortable: true, filter: "number", editable: true, aggFunc: "sum" },
198343
{ field: "date", headerName: "Date", sortable: true, filter: "date" },
199-
{ field: "status", headerName: "Status", sortable: true, filter: true }
344+
{ field: "status", headerName: "Status", sortable: true, filter: true, editable: true }
200345
],
201346
pagination: true,
202347
paginationPageSize: 5,
203348
animateRows: true,
204-
height: 400
349+
rowSelection: "multiple",
350+
editable: true,
351+
exportConfig: {
352+
enabled: true,
353+
fileName: "orders.csv"
354+
},
355+
statusBar: {
356+
enabled: true,
357+
aggregations: ["count", "sum", "avg"]
358+
},
359+
contextMenu: {
360+
enabled: true,
361+
items: ["copy", "export", "autoSizeAll"]
362+
},
363+
columnConfig: {
364+
resizable: true
365+
},
366+
height: 450
205367
}}
206-
title="Complete Example"
207-
description="Grid with pagination, sorting, filtering, and animated rows"
368+
title="Enterprise Features"
369+
description="Full-featured grid with editing, export, status bar, context menu, and more"
208370
/>
209371

210372
## Features
@@ -213,6 +375,13 @@ Note: `ag-grid-community` and `ag-grid-react` are peer dependencies and must be
213375
- **Zero Configuration**: Just import the package and use `type: 'aggrid'` in your schema
214376
- **Automatic Registration**: Components auto-register with the ComponentRegistry
215377
- **Full AG Grid Features**: Sorting, filtering, pagination, row selection, and more
378+
- **Inline Editing**: Edit cells directly with single or double-click modes
379+
- **CSV Export**: Built-in export functionality with customizable options
380+
- **Status Bar**: Display aggregations (count, sum, avg, min, max) at the bottom
381+
- **Context Menu**: Right-click menu with copy, export, and custom actions
382+
- **Column Configuration**: Global settings for resizable, sortable, and filterable columns
383+
- **Event Callbacks**: Handle cell clicks, selection changes, value edits, and exports
384+
- **Range Selection**: Excel-like range selection support
216385
- **Multiple Themes**: Quartz (default), Alpine, Balham, and Material
217386
- **Customizable**: Full access to AG Grid's GridOptions for advanced configuration
218387

@@ -221,15 +390,72 @@ Note: `ag-grid-community` and `ag-grid-react` are peer dependencies and must be
221390
```typescript
222391
{
223392
type: 'aggrid',
393+
394+
// Data
224395
rowData?: any[], // Grid data (required)
225396
columnDefs?: ColDef[], // Column definitions (required)
397+
398+
// Display
226399
pagination?: boolean, // Enable pagination (default: false)
227400
paginationPageSize?: number, // Rows per page (default: 10)
228401
theme?: 'quartz' | 'alpine' | 'balham' | 'material', // Grid theme (default: 'quartz')
229402
height?: number | string, // Grid height (default: 500)
230403
rowSelection?: 'single' | 'multiple', // Row selection mode
231404
domLayout?: 'normal' | 'autoHeight' | 'print', // Layout mode
232405
animateRows?: boolean, // Animate row changes (default: true)
406+
407+
// Editing
408+
editable?: boolean, // Enable cell editing (default: false)
409+
editType?: 'fullRow', // Row editing mode
410+
singleClickEdit?: boolean, // Start edit on single click (default: false)
411+
stopEditingWhenCellsLoseFocus?: boolean, // Stop editing on blur (default: true)
412+
413+
// Export
414+
exportConfig?: {
415+
enabled?: boolean, // Show export button (default: false)
416+
fileName?: string, // Export filename (default: 'export.csv')
417+
skipColumnHeaders?: boolean, // Skip column headers (default: false)
418+
onlySelected?: boolean, // Export only selected rows (default: false)
419+
allColumns?: boolean // Export all columns (default: false)
420+
},
421+
422+
// Status Bar
423+
statusBar?: {
424+
enabled?: boolean, // Show status bar (default: false)
425+
aggregations?: ('sum' | 'avg' | 'count' | 'min' | 'max')[] // Aggregations to show
426+
},
427+
428+
// Context Menu
429+
contextMenu?: {
430+
enabled?: boolean, // Enable context menu (default: false)
431+
items?: string[], // Menu items: 'copy', 'export', 'autoSizeAll', etc.
432+
customItems?: Array<{ // Custom menu items
433+
name: string,
434+
action: string,
435+
icon?: string,
436+
disabled?: boolean
437+
}>
438+
},
439+
440+
// Column Configuration
441+
columnConfig?: {
442+
resizable?: boolean, // Make all columns resizable
443+
sortable?: boolean, // Make all columns sortable
444+
filterable?: boolean, // Make all columns filterable
445+
},
446+
enableRangeSelection?: boolean, // Enable Excel-like range selection (default: false)
447+
enableCharts?: boolean, // Enable integrated charts (requires Enterprise, default: false)
448+
449+
// Event Callbacks
450+
callbacks?: {
451+
onCellClicked?: (event) => void, // Cell click handler
452+
onRowClicked?: (event) => void, // Row click handler
453+
onSelectionChanged?: (event) => void, // Selection change handler
454+
onCellValueChanged?: (event) => void, // Cell value change handler
455+
onExport?: (data, format) => void // Export handler
456+
},
457+
458+
// Advanced
233459
gridOptions?: GridOptions, // Advanced AG Grid options
234460
className?: string // Tailwind classes
235461
}
@@ -291,6 +517,95 @@ const schema: AgGridSchema = {
291517
};
292518
```
293519

520+
### Editing with Callbacks
521+
522+
```typescript
523+
const schema = {
524+
type: 'aggrid',
525+
rowData: [...],
526+
columnDefs: [
527+
{ field: 'name', headerName: 'Name', editable: true },
528+
{ field: 'email', headerName: 'Email', editable: true },
529+
{ field: 'role', headerName: 'Role', editable: false }
530+
],
531+
editable: true,
532+
singleClickEdit: false, // Double-click to edit
533+
callbacks: {
534+
onCellValueChanged: (event) => {
535+
console.log('Updated:', event.data);
536+
// Save to backend
537+
saveToBackend(event.data);
538+
}
539+
}
540+
};
541+
```
542+
543+
### Export with Selection
544+
545+
```typescript
546+
const schema = {
547+
type: 'aggrid',
548+
rowData: [...],
549+
columnDefs: [...],
550+
rowSelection: 'multiple',
551+
exportConfig: {
552+
enabled: true,
553+
fileName: 'selected-data.csv',
554+
onlySelected: true // Export only selected rows
555+
},
556+
callbacks: {
557+
onExport: (data, format) => {
558+
console.log(`Exported ${data.length} rows as ${format}`);
559+
}
560+
}
561+
};
562+
```
563+
564+
### Status Bar and Aggregations
565+
566+
```typescript
567+
const schema = {
568+
type: 'aggrid',
569+
rowData: [...],
570+
columnDefs: [
571+
{ field: 'product', headerName: 'Product' },
572+
{ field: 'price', headerName: 'Price', aggFunc: 'sum' },
573+
{ field: 'quantity', headerName: 'Quantity', aggFunc: 'avg' }
574+
],
575+
statusBar: {
576+
enabled: true,
577+
aggregations: ['count', 'sum', 'avg', 'min', 'max']
578+
},
579+
rowSelection: 'multiple' // Select rows to see aggregations
580+
};
581+
```
582+
583+
### Context Menu with Custom Actions
584+
585+
```typescript
586+
const schema = {
587+
type: 'aggrid',
588+
rowData: [...],
589+
columnDefs: [...],
590+
contextMenu: {
591+
enabled: true,
592+
items: ['copy', 'copyWithHeaders', 'separator', 'export', 'autoSizeAll'],
593+
customItems: [
594+
{
595+
name: 'Delete Row',
596+
action: 'delete',
597+
icon: '🗑️'
598+
},
599+
{
600+
name: 'View Details',
601+
action: 'view',
602+
icon: '👁️'
603+
}
604+
]
605+
}
606+
};
607+
```
608+
294609
### Advanced Configuration
295610

296611
```typescript

0 commit comments

Comments
 (0)