Skip to content

Commit

Permalink
Merge branch 'feat/add-allow-selection-prop' into alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
mguellsegarra committed Nov 25, 2024
2 parents c1a4028 + ed2bed8 commit e488474
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/components/InfiniteTable/InfiniteTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export type InfiniteTableProps = Omit<
statusComponent?: (status: any) => ReactNode;
strings?: Record<string, string>;
showPointerCursorInRows?: boolean;
enableRowSelection?: boolean;
cacheBlockSize?: number;
};

Expand Down Expand Up @@ -98,6 +99,7 @@ const InfiniteTableComp = forwardRef<InfiniteTableRef, InfiniteTableProps>(
hasStatusColumn = false,
strings = {},
showPointerCursorInRows = true,
enableRowSelection = true,
cacheBlockSize,
} = props;

Expand Down Expand Up @@ -268,7 +270,7 @@ const InfiniteTableComp = forwardRef<InfiniteTableRef, InfiniteTableProps>(
sortable: false,
lockPosition: "left",
lockPinned: true,
maxWidth: 30,
maxWidth: enableRowSelection ? 30 : 45,
pinned: "left",
resizable: false,
headerComponent: () => (
Expand All @@ -290,7 +292,11 @@ const InfiniteTableComp = forwardRef<InfiniteTableRef, InfiniteTableProps>(
: undefined,
} as ColDef;

const finalColumns = [statusColumn, checkboxColumn, ...restOfColumns];
const finalColumns = [
statusColumn,
...(enableRowSelection ? [checkboxColumn] : []),
...restOfColumns,
];

return finalColumns;
}, [
Expand All @@ -304,6 +310,7 @@ const InfiniteTableComp = forwardRef<InfiniteTableRef, InfiniteTableProps>(
applyAndUpdateNewState,
applyAutoFitState,
onColumnsChangedProps,
enableRowSelection,
]);

const scrollToSavedPosition = useCallback(() => {
Expand Down Expand Up @@ -512,7 +519,7 @@ const InfiniteTableComp = forwardRef<InfiniteTableRef, InfiniteTableProps>(
suppressCellFocus={true}
suppressRowClickSelection={true}
rowBuffer={DEFAULT_ROW_BUFFER}
rowSelection={"multiple"}
rowSelection={enableRowSelection ? "multiple" : undefined}
onDragStopped={debouncedOnColumnChanged}
onColumnResized={debouncedOnColumnResized}
rowModelType={"infinite"}
Expand Down

0 comments on commit e488474

Please sign in to comment.