Skip to content

Commit

Permalink
fix(Table): local data pagination, row selection doest not work (#3669)
Browse files Browse the repository at this point in the history
* fix(Table): 本地数据分页场景,行选中无效

* fix(table): lint error
  • Loading branch information
chaishi authored Dec 1, 2023
1 parent 3f11bbd commit 0055e2b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
14 changes: 1 addition & 13 deletions src/table/hooks/useRowSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function useRowSelect(
props: TdPrimaryTableProps,
tableSelectedClasses: TableClassName['tableSelectedClasses'],
) {
const { selectedRowKeys, columns, rowKey, data, pagination, reserveSelectedRowOnPaginate } = toRefs(props);
const { selectedRowKeys, columns, rowKey, data, reserveSelectedRowOnPaginate } = toRefs(props);
const currentPaginateData = ref<TableRowData[]>(data.value);
const selectedRowClassNames = ref();
const [tSelectedRowKeys, setTSelectedRowKeys] = useDefaultValue(
Expand Down Expand Up @@ -54,18 +54,6 @@ export default function useRowSelect(
return singleSelectCol.checkProps.allowUncheck;
});

watch(
[data, pagination, reserveSelectedRowOnPaginate],
() => {
if (reserveSelectedRowOnPaginate.value) return;
const { pageSize, current, defaultPageSize, defaultCurrent } = pagination.value;
const tPageSize = pageSize || defaultPageSize;
const tCurrent = current || defaultCurrent;
currentPaginateData.value = data.value.slice(tPageSize * (tCurrent - 1), tPageSize * tCurrent);
},
{ immediate: true },
);

watch(
[data, columns, tSelectedRowKeys, selectColumn, rowKey],
() => {
Expand Down
1 change: 1 addition & 0 deletions src/table/thead.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export default defineComponent({
const thClasses = [
thStyles.classes,
customClasses,
col.thClassName,
{
// 受 rowspan 影响,部分 tr > th:first-child 需要补足左边框
[this.tableHeaderClasses.thBordered]: thBorderMap.get(col),
Expand Down

0 comments on commit 0055e2b

Please sign in to comment.