Skip to content

Commit 3d0b37c

Browse files
rayman-demelloware
authored andcommitted
Feature: Allow range selection over multiple pages
1 parent 581f173 commit 3d0b37c

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

components/lib/datatable/DataTable.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1713,6 +1713,7 @@ export const DataTable = React.forwardRef((inProps, ref) => {
17131713
lazy={props.lazy}
17141714
loading={props.loading}
17151715
metaKeySelection={props.metaKeySelection}
1716+
multiPageRangeSelection={props.multiPageRangeSelection}
17161717
onCellClick={props.onCellClick}
17171718
onCellSelect={props.onCellSelect}
17181719
onCellUnselect={props.onCellUnselect}
@@ -1799,6 +1800,7 @@ export const DataTable = React.forwardRef((inProps, ref) => {
17991800
lazy={props.lazy}
18001801
loading={props.loading}
18011802
metaKeySelection={props.metaKeySelection}
1803+
multiPageRangeSelection={props.multiPageRangeSelection}
18021804
onCellClick={props.onCellClick}
18031805
onCellSelect={props.onCellSelect}
18041806
onCellUnselect={props.onCellUnselect}

components/lib/datatable/TableBody.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react';
22
import { localeOption } from '../api/Api';
33
import { ColumnBase } from '../column/ColumnBase';
4-
import { useMergeProps, useUnmountEffect, useUpdateEffect } from '../hooks/Hooks';
4+
import { useMergeProps, useUnmountEffect } from '../hooks/Hooks';
55
import { DomHandler, ObjectUtils } from '../utils/Utils';
66
import { BodyRow } from './BodyRow';
77
import { RowTogglerButton } from './RowTogglerButton';
@@ -174,7 +174,7 @@ export const TableBody = React.memo(
174174
};
175175

176176
const allowRangeSelection = (event) => {
177-
return isMultipleSelection() && event.originalEvent.shiftKey && anchorRowIndex.current !== null;
177+
return isMultipleSelection() && event.originalEvent.shiftKey && anchorRowIndex.current !== null && (anchorRowFirst.current === props.first || (props.multiPageRangeSelection && !props.lazy));
178178
};
179179

180180
const allowRowSelection = () => {
@@ -891,12 +891,6 @@ export const TableBody = React.memo(
891891
}
892892
});
893893

894-
useUpdateEffect(() => {
895-
if (props.paginator && isMultipleSelection()) {
896-
anchorRowIndex.current = null;
897-
}
898-
}, [props.first]);
899-
900894
useUnmountEffect(() => {
901895
if (props.dragSelection) {
902896
unbindDragSelectionEvents();

components/lib/datatable/datatable.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,6 +1285,10 @@ interface DataTableBaseProps<TValue extends DataTableValueArray> extends Omit<Re
12851285
* An array of SortMeta objects to sort the data by default in multiple sort mode.
12861286
*/
12871287
multiSortMeta?: DataTableSortMeta[] | null | undefined;
1288+
/**
1289+
* Defines whether a range selection can cover multiple pages.
1290+
*/
1291+
multiPageRangeSelection?: boolean;
12881292
/**
12891293
* Number of page links to display.
12901294
* @defaultValue 5

0 commit comments

Comments
 (0)