Skip to content

Commit 49a097a

Browse files
authored
[website] update multi header example (#187)
1 parent 4455ab4 commit 49a097a

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

website/src/examples/multi-header.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const columns = generateColumns(10)
1+
const columns = generateColumns(15)
22
const data = generateData(columns, 200)
33

44
const GroupCell = styled.div`
@@ -12,9 +12,12 @@ const GroupCell = styled.div`
1212
}
1313
`
1414

15-
columns[0].frozen = Column.FrozenDirection.LEFT
16-
columns[1].frozen = Column.FrozenDirection.LEFT
17-
columns[2].frozen = Column.FrozenDirection.RIGHT
15+
const fixedColumns = columns.map((column, columnIndex) => {
16+
let frozen
17+
if (columnIndex < 3) frozen = Column.FrozenDirection.LEFT
18+
if (columnIndex > 12) frozen = Column.FrozenDirection.RIGHT
19+
return { ...column, frozen, width: 100 }
20+
})
1821

1922
const headerRenderer = ({ cells, columns, headerIndex }) => {
2023
if (headerIndex === 2) return cells
@@ -34,7 +37,7 @@ const headerRenderer = ({ cells, columns, headerIndex }) => {
3437
if (
3538
columnIndex === columns.length - 1 ||
3639
nextColumn[Table.PlaceholderKey] ||
37-
idx === 3 - headerIndex
40+
idx === (headerIndex === 0 ? 4 : 2)
3841
) {
3942
groupCells.push(
4043
<GroupCell
@@ -55,7 +58,7 @@ const headerRenderer = ({ cells, columns, headerIndex }) => {
5558
export default () => (
5659
<Table
5760
fixed
58-
columns={columns}
61+
columns={fixedColumns}
5962
data={data}
6063
headerHeight={[30, 40, 50]}
6164
headerRenderer={headerRenderer}

website/src/utils/baseScope.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const Table = React.forwardRef((props, ref) => (
4949
<BaseTable ref={ref} width={700} height={400} {...props} />
5050
))
5151
Table.Column = Column
52+
Table.PlaceholderKey = BaseTable.PlaceholderKey
5253

5354
export default {
5455
React,

0 commit comments

Comments
 (0)