|
@@ -96,7 +96,15 @@ export interface NormalTableState<RecordType extends Record<string, any> = Data>
|
|
|
bodyHasScrollBar?: boolean;
|
|
|
prePropRowSelection?: TableStateRowSelection<RecordType>;
|
|
|
tableWidth?: number;
|
|
|
- prePagination?: Pagination
|
|
|
+ prePagination?: Pagination;
|
|
|
+ /**
|
|
|
+ * Disabled row keys in sorted and filtered data
|
|
|
+ */
|
|
|
+ allDisabledRowKeys?: BaseRowKeyType[];
|
|
|
+ /**
|
|
|
+ * Disabled row keys set in sorted and filtered data
|
|
|
+ */
|
|
|
+ allDisabledRowKeysSet?: Set<BaseRowKeyType>
|
|
|
}
|
|
|
|
|
|
export type TableStateRowSelection<RecordType extends Record<string, any> = Data> = (RowSelectionProps<RecordType> & { selectedRowKeysSet?: Set<(string | number)> }) | boolean;
|
|
@@ -244,11 +252,17 @@ class Table<RecordType extends Record<string, any>> extends BaseComponent<Normal
|
|
|
this.cachedFilteredSortedRowKeys = filteredSortedRowKeys;
|
|
|
this.cachedFilteredSortedRowKeysSet = new Set(filteredSortedRowKeys);
|
|
|
},
|
|
|
+ setAllDisabledRowKeys: allDisabledRowKeys => {
|
|
|
+ const allDisabledRowKeysSet = new Set(allDisabledRowKeys);
|
|
|
+ this.setState({ allDisabledRowKeys, allDisabledRowKeysSet });
|
|
|
+ },
|
|
|
getCurrentPage: () => get(this.state, 'pagination.currentPage', 1),
|
|
|
getCurrentPageSize: () => get(this.state, 'pagination.pageSize', numbers.DEFAULT_PAGE_SIZE),
|
|
|
getCachedFilteredSortedDataSource: () => this.cachedFilteredSortedDataSource,
|
|
|
getCachedFilteredSortedRowKeys: () => this.cachedFilteredSortedRowKeys,
|
|
|
getCachedFilteredSortedRowKeysSet: () => this.cachedFilteredSortedRowKeysSet,
|
|
|
+ getAllDisabledRowKeys: () => this.state.allDisabledRowKeys,
|
|
|
+ getAllDisabledRowKeysSet: () => this.state.allDisabledRowKeysSet,
|
|
|
notifyFilterDropdownVisibleChange: (visible, dataIndex) =>
|
|
|
this._invokeColumnFn(dataIndex, 'onFilterDropdownVisibleChange', visible),
|
|
|
notifyChange: (...args) => this.props.onChange(...args),
|
|
@@ -410,6 +424,8 @@ class Table<RecordType extends Record<string, any>> extends BaseComponent<Normal
|
|
|
allRowKeys: [], // row keys after paging
|
|
|
disabledRowKeys: [], // disabled row keys after paging
|
|
|
disabledRowKeysSet: new Set(),
|
|
|
+ allDisabledRowKeys: [],
|
|
|
+ allDisabledRowKeysSet: new Set(),
|
|
|
headWidths: [], // header cell width
|
|
|
bodyHasScrollBar: false,
|
|
|
prePropRowSelection: undefined,
|
|
@@ -471,8 +487,11 @@ class Table<RecordType extends Record<string, any>> extends BaseComponent<Normal
|
|
|
// The return value of getCheckboxProps affects the disabled rows
|
|
|
if (isFunction(getCheckboxProps)) {
|
|
|
const disabledRowKeys = getAllDisabledRowKeys({ dataSource, getCheckboxProps, childrenRecordName, rowKey });
|
|
|
+ const disabledRowKeysSet = new Set(disabledRowKeys);
|
|
|
willUpdateStates.disabledRowKeys = disabledRowKeys;
|
|
|
- willUpdateStates.disabledRowKeysSet = new Set(disabledRowKeys);
|
|
|
+ willUpdateStates.disabledRowKeysSet = disabledRowKeysSet;
|
|
|
+ willUpdateStates.allDisabledRowKeys = disabledRowKeys;
|
|
|
+ willUpdateStates.allDisabledRowKeysSet = disabledRowKeysSet;
|
|
|
}
|
|
|
willUpdateStates.rowSelection = newSelectionStates;
|
|
|
willUpdateStates.prePropRowSelection = rowSelection;
|
|
@@ -567,7 +586,9 @@ class Table<RecordType extends Record<string, any>> extends BaseComponent<Normal
|
|
|
// Temporarily use _dataSource=[...dataSource] for processing
|
|
|
const _dataSource = [...dataSource];
|
|
|
const filteredSortedDataSource = this.foundation.getFilteredSortedDataSource(_dataSource, stateQueries);
|
|
|
+ const allDataDisabledRowKeys = this.foundation.getAllDisabledRowKeys(filteredSortedDataSource);
|
|
|
this.foundation.setCachedFilteredSortedDataSource(filteredSortedDataSource);
|
|
|
+ this.foundation.setAllDisabledRowKeys(allDataDisabledRowKeys);
|
|
|
states.dataSource = filteredSortedDataSource;
|
|
|
|
|
|
if (this.props.groupBy) {
|
|
@@ -814,7 +835,7 @@ class Table<RecordType extends Record<string, any>> extends BaseComponent<Normal
|
|
|
};
|
|
|
|
|
|
renderSelection = (record = {} as any, inHeader = false): React.ReactNode => {
|
|
|
- const { rowSelection, disabledRowKeysSet } = this.state;
|
|
|
+ const { rowSelection, allDisabledRowKeysSet } = this.state;
|
|
|
|
|
|
if (rowSelection && typeof rowSelection === 'object') {
|
|
|
const { selectedRowKeys = [], selectedRowKeysSet = new Set(), getCheckboxProps, disabled } = rowSelection;
|
|
@@ -823,7 +844,7 @@ class Table<RecordType extends Record<string, any>> extends BaseComponent<Normal
|
|
|
const columnKey = get(rowSelection, 'key', strings.DEFAULT_KEY_COLUMN_SELECTION);
|
|
|
const allRowKeys = this.cachedFilteredSortedRowKeys;
|
|
|
const allRowKeysSet = this.cachedFilteredSortedRowKeysSet;
|
|
|
- const allIsSelected = this.foundation.allIsSelected(selectedRowKeysSet, disabledRowKeysSet, allRowKeys);
|
|
|
+ const allIsSelected = this.foundation.allIsSelected(selectedRowKeysSet, allDisabledRowKeysSet, allRowKeys);
|
|
|
const hasRowSelected = this.foundation.hasRowSelected(selectedRowKeys, allRowKeysSet);
|
|
|
return (
|
|
|
<ColumnSelection
|
|
@@ -832,8 +853,8 @@ class Table<RecordType extends Record<string, any>> extends BaseComponent<Normal
|
|
|
key={columnKey}
|
|
|
selected={allIsSelected}
|
|
|
indeterminate={hasRowSelected && !allIsSelected}
|
|
|
- onChange={(status, e) => {
|
|
|
- this.toggleSelectAllRow(status, e);
|
|
|
+ onChange={(selected, e) => {
|
|
|
+ this.toggleSelectAllRow(selected, e);
|
|
|
}}
|
|
|
/>
|
|
|
);
|
|
@@ -1005,8 +1026,8 @@ class Table<RecordType extends Record<string, any>> extends BaseComponent<Normal
|
|
|
this.foundation.handleSelectRow(realKey, selected, e);
|
|
|
};
|
|
|
|
|
|
- toggleSelectAllRow = (status: boolean, e: TableSelectionCellEvent) => {
|
|
|
- this.foundation.handleSelectAllRow(status, e);
|
|
|
+ toggleSelectAllRow = (selected: boolean, e: TableSelectionCellEvent) => {
|
|
|
+ this.foundation.handleSelectAllRow(selected, e);
|
|
|
};
|
|
|
|
|
|
/**
|