Skip to content

Commit

Permalink
feat: sync changes from v2 to v2-develop
Browse files Browse the repository at this point in the history
  • Loading branch information
mguellsegarra authored and github-actions[bot] committed Dec 12, 2024
1 parent bc4df2a commit 8fb6a2f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gisce/react-formiga-table",
"version": "1.8.5",
"version": "1.9.0",
"engines": {
"node": "20.5.0"
},
Expand Down
20 changes: 20 additions & 0 deletions src/components/InfiniteTable/InfiniteTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ export type InfiniteTableRef = {
setSelectedRows: (keys: number[]) => void;
unselectAll: () => void;
refresh: () => void;
updateRows: (updates: Array<Record<string, any>>) => void;
getVisibleRowIds: () => string[];
};

const InfiniteTableComp = forwardRef<InfiniteTableRef, InfiniteTableProps>(
Expand Down Expand Up @@ -139,6 +141,24 @@ const InfiniteTableComp = forwardRef<InfiniteTableRef, InfiniteTableProps>(
gridRef.current?.api?.deselectAll();
gridRef.current?.api?.purgeInfiniteCache();
},
updateRows: (updates: Array<Record<string, any>>) => {
if (!gridRef.current?.api) return;

updates.forEach((update) => {
const node = gridRef.current?.api
.getRenderedNodes()
.find((node) => node.data.id === update.id);
if (node) {
// Update specific fields without refreshing entire row
node.setData({ ...node.data, ...update });
}
});
},
getVisibleRowIds: () => {
if (!gridRef.current?.api) return [];
const visibleNodes = gridRef.current.api.getRenderedNodes();
return visibleNodes.map((node) => node?.data?.id);
},
}));

const columns = useDeepArrayMemo(columnsProps, "key");
Expand Down

0 comments on commit 8fb6a2f

Please sign in to comment.