Skip to content

Commit

Permalink
try to badd back open groups
Browse files Browse the repository at this point in the history
  • Loading branch information
dominic-lcw committed Sep 29, 2024
1 parent bf8aaca commit 13bff5e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 25 deletions.
32 changes: 9 additions & 23 deletions app/src/components/grid/gridStates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export async function initStateTable() {
const query = `
CREATE TABLE IF NOT EXISTS grid_states_test (
table_name VARCHAR,
userSaved VARCHAR DEFAULT 'false', -- Added for Memory Store (MS) and Memory Recall (MV)
userSaved VARCHAR, -- Added for Memory Store (MS) and Memory Recall (MV)
state VARCHAR,
columnState VARCHAR,
PRIMARY KEY (table_name, userSaved)
Expand All @@ -25,7 +25,7 @@ export function fetchPreviousState(tableName: string) {
const query = `
SELECT table_name, state, columnState FROM grid_states_test
WHERE table_name = '${tableName}'
AND userSaved = 'false';
AND userSaved = 'auto';
`;
const arrowResult = await connection.query(query);
const result = arrowResult.toArray().map((row) => row.toJSON());
Expand Down Expand Up @@ -94,27 +94,13 @@ export async function applySavedState(
gridApi.setFilterModel(gridState.filter.filterModel);
}

// await new Promise<void>((resolve) => {
// gridApi.forEachNode((node) => {
// if (node.group) {
// console.log("leudom node", node.key);
// node.setExpanded(true);
// }
// });
// resolve();
// });

// Set Row Group Expansion
// if (
// gridState.rowGroupExpansion &&
// Array.isArray(gridState.rowGroupExpansion)
// ) {
// gridApi.forEachNode((node) => {
// if (gridState.rowGroupExpansion.includes(node.key)) {
// node.setExpanded(true);
// }
// });
// }
// Open groups
const openGroups = gridState.rowGroupExpansion.expandedRowGroupIds;
gridApi.forEachNode((node) => {
if (openGroups.includes(node.id)) {
node.setExpanded(true);
}
});
}
}

Expand Down
4 changes: 2 additions & 2 deletions app/src/components/grid/stdGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,15 +272,15 @@ const StdAgGrid: React.FC<StdAgGridProps> = (props) => {
};

const onFirstDataRendered = useCallback(
(params: any) => {
async (params: any) => {
const endTime = performance.now();
const execTime = endTime - startTime.current;
setExecTime(execTime);
setLoading(false);

// States
initStateTable(); // Create table if not exists.
applySavedState(gridApi, props.tableName, "auto");
await applySavedState(gridApi, props.tableName, "auto");
},
[gridApi],
);
Expand Down

0 comments on commit 13bff5e

Please sign in to comment.