跳至主要内容

合併儲存格

合併儲存格的功能,可設定 表頭儲存格合併、內容儲存格合併、Footer儲存格合併

如果要使用表頭儲存格合併,需要在 title 參數中的欄位 colSpan 設定,例如 colSpan: 3 如果要使用內容儲存格合併,需要在 data.field 參數中的欄位 colSpan 設定,例如 colSpan: 4

import AcroolTable from '@acrool/react-table';

const Colspan = () => {
return <AcroolTable
title={{
avatar: {text: '#', col: 50, titleAlign: 'center', dataAlign: 'center', colSpan: 3},
name: {text: 'Name', col: 'auto'},
amount: {text: 'Amount', col: '80px', titleAlign: 'right', dataAlign: 'right'},
role: {text: 'Role', col: '120px'},
createdAt:{text: 'Crated', col: '110px'},
joined: {text: 'Joined', col: '80px'},
}}
data={data.slice(0, 6).map((row, index) => {
return {
id: row.id,
field: {
avatar: <Avatar src={row.avatar}/>,
name: row.name,
role: row.role,
createdAt: dayjs(row.createdAt).format('MM/DD'),
joined: row.isJoined ? 'Y':'N',
amount: {
colSpan: index === 0 ? 4: 1,
dataAlign: index === 0 ? 'center': 'right',
value: index === 0 ? 'ColSpan 4': `$ ${formatCurrency(row.amount)}`
},
},
};
})}
/>
}


Colspan 3
Role
Crated
Joined
Jack WuColSpan 4
Imagine Chiu$ 99Guest12/15Y
Jason Dinwiddie$ 880Manage12/12N
Gloria Lu$ 12,300Guest12/11Y
Adam Bolton$ 2,500Guest12/12N
Stanley McQueen$ 200Guest12/12N
Loading...
Show 1 - 0 itemTotal 0 item / 1 Page