Skip to content

Commit cdf2c59

Browse files
committed
fix(table): fix the problem that multi-level header configuration does not take effect
1 parent 36a7e70 commit cdf2c59

File tree

3 files changed

+30
-93
lines changed

3 files changed

+30
-93
lines changed

CHANGELOG.zh_CN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
- 修复`useECharts``resize`时不能自适应,报错
3131
- 修复`useWatermark`在清空后`resize`未删除
3232
- 修复表单校验问题
33+
- 修复多级表头配置不生效问题
3334

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

src/components/Table/src/hooks/useColumns.ts

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,11 @@ export function useColumns(
2323
}
2424
let pushIndexColumns = false;
2525
columns.forEach((item) => {
26-
const { key, dataIndex } = item;
27-
item.align = item.align || 'center';
28-
if (ellipsis) {
29-
if (!key) {
30-
item.key = dataIndex;
31-
}
32-
if (!isBoolean(item.ellipsis)) {
33-
Object.assign(item, {
34-
ellipsis,
35-
});
36-
}
37-
}
26+
const { children } = item;
27+
handleItem(item, !!ellipsis);
28+
29+
handleChildren(children, !!ellipsis);
30+
3831
const indIndex = columns.findIndex((column) => column.flag === 'INDEX');
3932
if (showIndexColumn && !isTreeTable) {
4033
pushIndexColumns = indIndex === -1;
@@ -88,6 +81,30 @@ export function useColumns(
8881
cacheColumnsRef.value = columns;
8982
});
9083

84+
function handleItem(item: BasicColumn, ellipsis: boolean) {
85+
const { key, dataIndex } = item;
86+
item.align = item.align || 'center';
87+
if (ellipsis) {
88+
if (!key) {
89+
item.key = dataIndex;
90+
}
91+
if (!isBoolean(item.ellipsis)) {
92+
Object.assign(item, {
93+
ellipsis,
94+
});
95+
}
96+
}
97+
}
98+
99+
function handleChildren(children: BasicColumn[] | undefined, ellipsis: boolean) {
100+
if (!children) return;
101+
children.forEach((item) => {
102+
const { children } = item;
103+
handleItem(item, ellipsis);
104+
handleChildren(children, ellipsis);
105+
});
106+
}
107+
91108
function setColumns(columns: BasicColumn[] | string[]) {
92109
if (!isArray(columns)) return;
93110

src/design/ant/selection.less

Lines changed: 0 additions & 81 deletions
This file was deleted.

0 commit comments

Comments
 (0)