diff --git a/packages/amis/src/renderers/Table/TableRow.tsx b/packages/amis/src/renderers/Table/TableRow.tsx index 03040c237..5359d14fc 100644 --- a/packages/amis/src/renderers/Table/TableRow.tsx +++ b/packages/amis/src/renderers/Table/TableRow.tsx @@ -6,7 +6,7 @@ import {Action} from '../Action'; import {isClickOnInput, createObject} from 'amis-core'; interface TableRowProps extends Pick { - onCheck: (item: IRow) => Promise; + onCheck: (item: IRow, value: boolean, shift?: boolean) => Promise; onRowClick: (item: IRow, index: number) => Promise | void>; onRowDbClick: ( item: IRow, @@ -85,7 +85,7 @@ export class TableRow extends React.Component { // item.toggle(); } else { if (item.checkable && item.isCheckAvaiableOnClick) { - onCheck?.(item); + onCheck?.(item, !item.checked, (e.nativeEvent as MouseEvent).shiftKey); } } } diff --git a/packages/amis/src/renderers/Table/index.tsx b/packages/amis/src/renderers/Table/index.tsx index 01d3d4b1f..ac21fd28c 100644 --- a/packages/amis/src/renderers/Table/index.tsx +++ b/packages/amis/src/renderers/Table/index.tsx @@ -871,13 +871,15 @@ export default class Table extends React.Component { onAction(e, action, ctx); } - async handleCheck(item: IRow, value: boolean, shift?: boolean) { + async handleCheck(item: IRow, value?: boolean, shift?: boolean) { const {store, data, dispatchEvent, selectable} = this.props; if (!selectable) { return; } + value = value !== undefined ? value : !item.checked; + let rows = [item]; if (shift) { rows = store.getToggleShiftRows(item);