Skip to content

Commit 2012d49

Browse files
committed
Feature: Allow range selection over multiple pages
1 parent d49a061 commit 2012d49

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

components/lib/datatable/DataTable.js

+2
Original file line numberDiff line numberDiff line change
@@ -1675,6 +1675,7 @@ export const DataTable = React.forwardRef((inProps, ref) => {
16751675
lazy={props.lazy}
16761676
loading={props.loading}
16771677
metaKeySelection={props.metaKeySelection}
1678+
multiPageRangeSelection={props.multiPageRangeSelection}
16781679
onCellClick={props.onCellClick}
16791680
onCellSelect={props.onCellSelect}
16801681
onCellUnselect={props.onCellUnselect}
@@ -1761,6 +1762,7 @@ export const DataTable = React.forwardRef((inProps, ref) => {
17611762
lazy={props.lazy}
17621763
loading={props.loading}
17631764
metaKeySelection={props.metaKeySelection}
1765+
multiPageRangeSelection={props.multiPageRangeSelection}
17641766
onCellClick={props.onCellClick}
17651767
onCellSelect={props.onCellSelect}
17661768
onCellUnselect={props.onCellUnselect}

components/lib/datatable/TableBody.js

+2-8
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';
@@ -167,7 +167,7 @@ export const TableBody = React.memo(
167167
};
168168

169169
const allowRangeSelection = (event) => {
170-
return isMultipleSelection() && event.originalEvent.shiftKey && anchorRowIndex.current !== null;
170+
return isMultipleSelection() && event.originalEvent.shiftKey && anchorRowIndex.current !== null && (anchorRowFirst.current === props.first || (props.multiPageRangeSelection && !props.lazy));
171171
};
172172

173173
const allowRowSelection = () => {
@@ -876,12 +876,6 @@ export const TableBody = React.memo(
876876
}
877877
});
878878

879-
useUpdateEffect(() => {
880-
if (props.paginator && isMultipleSelection()) {
881-
anchorRowIndex.current = null;
882-
}
883-
}, [props.first]);
884-
885879
useUnmountEffect(() => {
886880
if (props.dragSelection) {
887881
unbindDragSelectionEvents();

components/lib/datatable/datatable.d.ts

+4
Original file line numberDiff line numberDiff line change
@@ -1248,6 +1248,10 @@ interface DataTableBaseProps<TValue extends DataTableValueArray> extends Omit<Re
12481248
* An array of SortMeta objects to sort the data by default in multiple sort mode.
12491249
*/
12501250
multiSortMeta?: DataTableSortMeta[] | null | undefined;
1251+
/**
1252+
* Defines whether a range selection can cover multiple pages.
1253+
*/
1254+
multiPageRangeSelection?: boolean;
12511255
/**
12521256
* Number of page links to display.
12531257
* @defaultValue 5

0 commit comments

Comments
 (0)