2018-04-03 06:34:54 +00:00
|
|
|
<cn>
|
|
|
|
#### 表头分组
|
|
|
|
`columns[n]` 可以内嵌 `children`,以渲染分组表头。
|
|
|
|
</cn>
|
|
|
|
|
|
|
|
<us>
|
|
|
|
#### Grouping table head
|
|
|
|
Group table head with `columns[n].children`.
|
|
|
|
</us>
|
|
|
|
|
|
|
|
```html
|
|
|
|
<template>
|
|
|
|
<a-table
|
|
|
|
:columns="columns"
|
|
|
|
:dataSource="data"
|
|
|
|
bordered
|
|
|
|
size="middle"
|
|
|
|
:scroll="{ x: '130%', y: 240 }"
|
|
|
|
/>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
const columns = [{
|
|
|
|
title: 'Name',
|
|
|
|
dataIndex: 'name',
|
|
|
|
key: 'name',
|
|
|
|
width: 100,
|
|
|
|
fixed: 'left',
|
|
|
|
filters: [{
|
|
|
|
text: 'Joe',
|
|
|
|
value: 'Joe',
|
|
|
|
}, {
|
|
|
|
text: 'John',
|
|
|
|
value: 'John',
|
|
|
|
}],
|
|
|
|
onFilter: (value, record) => record.name.indexOf(value) === 0,
|
|
|
|
}, {
|
|
|
|
title: 'Other',
|
|
|
|
children: [{
|
|
|
|
title: 'Age',
|
|
|
|
dataIndex: 'age',
|
|
|
|
key: 'age',
|
|
|
|
width: 200,
|
|
|
|
sorter: (a, b) => a.age - b.age,
|
|
|
|
}, {
|
|
|
|
title: 'Address',
|
|
|
|
children: [{
|
|
|
|
title: 'Street',
|
|
|
|
dataIndex: 'street',
|
|
|
|
key: 'street',
|
|
|
|
width: 200,
|
|
|
|
}, {
|
|
|
|
title: 'Block',
|
|
|
|
children: [{
|
|
|
|
title: 'Building',
|
|
|
|
dataIndex: 'building',
|
|
|
|
key: 'building',
|
|
|
|
width: 100,
|
|
|
|
}, {
|
|
|
|
title: 'Door No.',
|
|
|
|
dataIndex: 'number',
|
|
|
|
key: 'number',
|
|
|
|
width: 100,
|
|
|
|
}],
|
|
|
|
}],
|
|
|
|
}],
|
|
|
|
}, {
|
|
|
|
title: 'Company',
|
|
|
|
children: [{
|
|
|
|
title: 'Company Address',
|
|
|
|
dataIndex: 'companyAddress',
|
|
|
|
key: 'companyAddress',
|
|
|
|
}, {
|
|
|
|
title: 'Company Name',
|
|
|
|
dataIndex: 'companyName',
|
|
|
|
key: 'companyName',
|
|
|
|
}],
|
|
|
|
}, {
|
|
|
|
title: 'Gender',
|
|
|
|
dataIndex: 'gender',
|
|
|
|
key: 'gender',
|
2018-09-05 13:28:54 +00:00
|
|
|
width: 80,
|
2018-04-03 06:34:54 +00:00
|
|
|
fixed: 'right',
|
|
|
|
}];
|
|
|
|
|
|
|
|
const data = [];
|
|
|
|
for (let i = 0; i < 100; i++) {
|
|
|
|
data.push({
|
|
|
|
key: i,
|
|
|
|
name: 'John Brown',
|
|
|
|
age: i + 1,
|
|
|
|
street: 'Lake Park',
|
|
|
|
building: 'C',
|
|
|
|
number: 2035,
|
|
|
|
companyAddress: 'Lake Street 42',
|
|
|
|
companyName: 'SoftLake Co',
|
|
|
|
gender: 'M',
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
data,
|
|
|
|
columns,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
```
|