Skip to content

Commit

Permalink
fix(table): fix the problem that multi-level header configuration doe…
Browse files Browse the repository at this point in the history
…s not take effect
  • Loading branch information
anncwb committed Nov 8, 2020
1 parent 36a7e70 commit cdf2c59
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 93 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
- 修复`useECharts``resize`时不能自适应,报错
- 修复`useWatermark`在清空后`resize`未删除
- 修复表单校验问题
- 修复多级表头配置不生效问题

## 2.0.0-rc.8 (2020-11-2)

Expand Down
41 changes: 29 additions & 12 deletions src/components/Table/src/hooks/useColumns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,11 @@ export function useColumns(
}
let pushIndexColumns = false;
columns.forEach((item) => {
const { key, dataIndex } = item;
item.align = item.align || 'center';
if (ellipsis) {
if (!key) {
item.key = dataIndex;
}
if (!isBoolean(item.ellipsis)) {
Object.assign(item, {
ellipsis,
});
}
}
const { children } = item;
handleItem(item, !!ellipsis);

handleChildren(children, !!ellipsis);

const indIndex = columns.findIndex((column) => column.flag === 'INDEX');
if (showIndexColumn && !isTreeTable) {
pushIndexColumns = indIndex === -1;
Expand Down Expand Up @@ -88,6 +81,30 @@ export function useColumns(
cacheColumnsRef.value = columns;
});

function handleItem(item: BasicColumn, ellipsis: boolean) {
const { key, dataIndex } = item;
item.align = item.align || 'center';
if (ellipsis) {
if (!key) {
item.key = dataIndex;
}
if (!isBoolean(item.ellipsis)) {
Object.assign(item, {
ellipsis,
});
}
}
}

function handleChildren(children: BasicColumn[] | undefined, ellipsis: boolean) {
if (!children) return;
children.forEach((item) => {
const { children } = item;
handleItem(item, ellipsis);
handleChildren(children, ellipsis);
});
}

function setColumns(columns: BasicColumn[] | string[]) {
if (!isArray(columns)) return;

Expand Down
81 changes: 0 additions & 81 deletions src/design/ant/selection.less

This file was deleted.

0 comments on commit cdf2c59

Please sign in to comment.