Skip to content

Commit 50948cb

Browse files
Copilothotlong
andcommitted
fix(plugin-aggrid): Address code review feedback
- Fix deprecated columnApi usage, use api.autoSizeAllColumns() and api.resetColumnState() - Improve custom context menu action handling to use callbacks - Clean up ExportConfig type to match actual implementation - Update documentation to reflect accurate API Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 1f63b6b commit 50948cb

3 files changed

Lines changed: 14 additions & 8 deletions

File tree

packages/plugin-aggrid/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ const schema: AgGridSchema = {
143143
exportConfig?: {
144144
enabled?: boolean, // Show export button (default: false)
145145
fileName?: string, // Export filename (default: 'export.csv')
146-
includeHeaders?: boolean, // Include column headers (default: true)
146+
skipColumnHeaders?: boolean, // Skip column headers in export (default: false)
147147
onlySelected?: boolean, // Export only selected rows (default: false)
148148
allColumns?: boolean // Export all columns (default: false)
149149
},

packages/plugin-aggrid/src/AgGridImpl.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,17 +131,17 @@ export default function AgGridImpl({
131131
items.push({
132132
name: 'Auto-size All Columns',
133133
action: () => {
134-
if (gridRef.current?.columnApi) {
135-
gridRef.current.columnApi.autoSizeAllColumns();
134+
if (gridRef.current?.api) {
135+
gridRef.current.api.autoSizeAllColumns();
136136
}
137137
},
138138
});
139139
} else if (item === 'resetColumns') {
140140
items.push({
141141
name: 'Reset Columns',
142142
action: () => {
143-
if (gridRef.current?.columnApi) {
144-
gridRef.current.columnApi.resetColumnState();
143+
if (gridRef.current?.api) {
144+
gridRef.current.api.resetColumnState();
145145
}
146146
},
147147
});
@@ -161,7 +161,15 @@ export default function AgGridImpl({
161161
icon: customItem.icon,
162162
disabled: customItem.disabled,
163163
action: () => {
164-
console.log(`Custom action: ${customItem.action}`, params.node?.data);
164+
// Trigger callback if defined
165+
if (callbacks?.onCellClicked) {
166+
// Invoke with the menu item action and row data
167+
const syntheticEvent = {
168+
...params,
169+
customAction: customItem.action,
170+
} as any;
171+
callbacks.onCellClicked(syntheticEvent);
172+
}
165173
},
166174
});
167175
});

packages/plugin-aggrid/src/types.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ export interface AgGridCallbacks {
2525
export interface ExportConfig {
2626
enabled?: boolean;
2727
fileName?: string;
28-
formats?: ('csv' | 'excel')[];
29-
includeHeaders?: boolean;
3028
skipColumnHeaders?: boolean;
3129
allColumns?: boolean;
3230
onlySelected?: boolean;

0 commit comments

Comments
 (0)