|
1 |
| -import { ColDef, ICellRendererParams } from 'ag-grid-community'; |
| 1 | +import { ColDef, ColSpanParams, ICellRendererParams } from 'ag-grid-community'; |
2 | 2 | import { AgGridReact } from 'ag-grid-react';
|
3 | 3 | import { useEffect } from 'react';
|
4 | 4 |
|
@@ -60,7 +60,8 @@ export const DatabaseGrid = ({
|
60 | 60 |
|
61 | 61 | const columns: ColDef[] = columnNames.map((key) => ({
|
62 | 62 | field: key,
|
63 |
| - colSpan: newRowColSpan, |
| 63 | + colSpan: (params: ColSpanParams<Record<string, string>, unknown>) => |
| 64 | + newRowColSpan(params, columnNames.length + 1), |
64 | 65 | cellRendererSelector: (
|
65 | 66 | params: ICellRendererParams<Record<string, string>>,
|
66 | 67 | ) => addRowCellRenderer(params, columnNames, setRowData),
|
@@ -97,20 +98,15 @@ export const DatabaseGrid = ({
|
97 | 98 | const columnNames = getColumnNames(colDefs);
|
98 | 99 | const newColDef: ColDef = {
|
99 | 100 | field: columnName,
|
100 |
| - colSpan: newRowColSpan, |
| 101 | + colSpan: (params: ColSpanParams<Record<string, string>, unknown>) => |
| 102 | + newRowColSpan(params, columnNames.length + 1), |
101 | 103 | cellRendererSelector: (
|
102 | 104 | params: ICellRendererParams<Record<string, string>>,
|
103 | 105 | ) => addRowCellRenderer(params, columnNames, setRowData),
|
104 | 106 | };
|
105 | 107 |
|
106 | 108 | setColDefs((prev) => {
|
107 |
| - const addColumn = prev?.pop(); |
108 |
| - |
109 |
| - return [ |
110 |
| - ...(prev ?? []), |
111 |
| - newColDef, |
112 |
| - ...(addColumn !== undefined ? [addColumn] : []), |
113 |
| - ]; |
| 109 | + return [...(prev ?? []), newColDef]; |
114 | 110 | });
|
115 | 111 |
|
116 | 112 | void createColumns(documentId, tableId, [
|
|
0 commit comments