ant-design-vue/components/vc-table/demo/subTable.js

64 lines
1.2 KiB
JavaScript
Raw Normal View History

2018-03-27 14:41:41 +00:00
/* eslint-disable no-console,func-names,react/no-multi-comp */
2019-01-12 03:33:27 +00:00
import Table from '../index';
import '../assets/index.less';
2018-03-27 14:41:41 +00:00
const data = [
{
a: 'a1',
},
{
a: 'a2',
b: 'b2',
children: [
{
a: 'a2-1',
b: 'b2-1',
},
{
a: 'a2-2',
b: 'b2-2',
},
],
},
{
a: 'a3',
c: 'c3',
d: 'd3',
},
2019-01-12 03:33:27 +00:00
];
2018-03-27 14:41:41 +00:00
export default {
methods: {
2019-01-12 03:33:27 +00:00
handleClick(record, e) {
e.preventDefault();
console.log(record.a);
2018-03-27 14:41:41 +00:00
},
},
2019-01-12 03:33:27 +00:00
render() {
2018-03-27 14:41:41 +00:00
const columns = [
{ title: 'title1', dataIndex: 'a', key: 'a', width: 100 },
{ title: 'title2', dataIndex: 'b', key: 'b', width: 100 },
{ title: 'title3', dataIndex: 'c', key: 'c', width: 200 },
{
2019-01-12 03:33:27 +00:00
title: 'Operations',
dataIndex: '',
key: 'x',
customRender: (text, record) => {
return (
<a href="javascript:;" onClick={e => this.handleClick(record, e)}>
click {record.a}
</a>
);
2018-03-27 14:41:41 +00:00
},
},
2019-01-12 03:33:27 +00:00
];
2018-03-27 14:41:41 +00:00
return (
<div>
<h2>sub table</h2>
2019-01-12 03:33:27 +00:00
<Table columns={columns} expandIconAsCell data={data} rowKey={record => record.a} />
2018-03-27 14:41:41 +00:00
</div>
2019-01-12 03:33:27 +00:00
);
2018-03-27 14:41:41 +00:00
},
2019-01-12 03:33:27 +00:00
};