diff --git a/packages/arco-lib/src/components/Table/Table.tsx b/packages/arco-lib/src/components/Table/Table.tsx index 6207439a..6faefbe7 100644 --- a/packages/arco-lib/src/components/Table/Table.tsx +++ b/packages/arco-lib/src/components/Table/Table.tsx @@ -215,7 +215,7 @@ export const Table = implementRuntimeComponent({ } = pagination; const rowSelectionType = rowSelectionTypeMap[cProps.rowSelectionType]; - const currentChecked = useRef<(string | number)[]>([]); + const currentChecked = useRef[]>([]); const currentClickedRow = useRef<(string | number)[] | undefined>(undefined); const [currentPage, setCurrentPage] = useStateValue( @@ -274,15 +274,15 @@ export const Table = implementRuntimeComponent({ // reset selectedRows state when data changed useEffect(() => { - const selectedRows = currentPageData.filter(d => - currentChecked.current.includes(d[rowKey]) + const currentCheckedRowKeys = currentChecked.current.map( + row => row[rowKey] as string ); // TODO: Save clickedRow state when rowkey changes, save the UI of clickedRow when turning the page const clickedRow = currentPageData.find(d => d[rowKey] === currentClickedRow.current); if (!clickedRow) currentClickedRow.current = undefined; mergeState({ - selectedRowKeys: selectedRows.map(r => r[rowKey]), - selectedRows, + selectedRowKeys: currentCheckedRowKeys, + selectedRows: currentChecked.current, clickedRow, }); }, [currentPageData, mergeState, rowKey]); @@ -573,7 +573,7 @@ export const Table = implementRuntimeComponent({ // This option is required to achieve multi-selection across pages when customizing paging preserveSelectedRowKeys: useCustomPagination ? checkCrossPage : undefined, onChange(selectedRowKeys, selectedRows) { - currentChecked.current = selectedRowKeys; + currentChecked.current = selectedRows; mergeState({ selectedRowKeys: selectedRowKeys as string[], selectedRows, diff --git a/packages/arco-lib/src/generated/types/Table.ts b/packages/arco-lib/src/generated/types/Table.ts index 70885f63..ab0aff35 100644 --- a/packages/arco-lib/src/generated/types/Table.ts +++ b/packages/arco-lib/src/generated/types/Table.ts @@ -367,7 +367,8 @@ export const TablePropsSpec = Type.Object({ checkCrossPage: Type.Boolean({ title: 'Check Cross Page', category: Category.Basic, - description: 'Whether the checkboxes in multi-select mode cross pages', + description: + 'Whether the checkboxes in multi-select mode cross pages。Please note that with this option on, if the data changes, the previous selected state will still be cached', }), rowSelectionType: StringUnion(['multiple', 'single', 'disable'], { title: 'Row Selection Type', diff --git a/packages/arco-lib/src/widgets/TablePrimaryKeyWidget.tsx b/packages/arco-lib/src/widgets/TablePrimaryKeyWidget.tsx index af00fb0e..c86f6482 100644 --- a/packages/arco-lib/src/widgets/TablePrimaryKeyWidget.tsx +++ b/packages/arco-lib/src/widgets/TablePrimaryKeyWidget.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { WidgetProps, implementWidget } from '@sunmao-ui/editor-sdk'; +import { WidgetProps, implementWidget, isExpression } from '@sunmao-ui/editor-sdk'; import { ColumnSpec } from '../generated/types/Table'; import { Static } from '@sinclair/typebox'; import { Select } from '@arco-design/web-react'; @@ -10,9 +10,13 @@ type TablePrimaryKeyWidgetID = 'arco/v1/primaryKey'; export const _TablePrimaryKeyWidget: React.FC< WidgetProps > = props => { - const { value, onChange, component } = props; + const { value, onChange, component, services } = props; const { properties } = component; - const columns = properties.columns as Static[]; + const columns = ( + isExpression(properties.columns) + ? services.stateManager.deepEval(properties.columns as string) + : properties.columns + ) as Static[]; const keys = columns.map(c => c.dataIndex);