ant-design-vue/components/vc-table/demo/fixedColumns-auto-height.js

65 lines
2.1 KiB
JavaScript
Raw Normal View History

2019-12-21 18:37:33 +08:00
/* eslint-disable no-console,func-names */
2019-01-12 11:33:27 +08:00
import Table from '../index';
import '../assets/index.less';
2018-03-26 23:05:29 +08:00
const data = [
{ a: '123', b: 'xxxxxxxx', d: 3, key: '1', title: 'hello' },
{ a: 'cdd', b: 'edd12221', d: 3, key: '2', title: 'hello' },
{ a: '133', c: 'edd12221', d: 2, key: '3', title: 'hello' },
{ a: '133', c: 'edd12221', d: 2, key: '4', title: 'hello' },
{ a: '133', c: 'edd12221', d: 2, key: '5', title: 'hello' },
{ a: '133', c: 'edd12221', d: 2, key: '6', title: 'hello' },
{ a: '133', c: 'edd12221', d: 2, key: '7', title: 'hello' },
{ a: '133', c: 'edd12221', d: 2, key: '8', title: 'hello' },
{ a: '133', c: 'edd12221', d: 2, key: '9', title: 'hello' },
2019-01-12 11:33:27 +08:00
];
2018-03-26 23:05:29 +08:00
export default {
2019-01-12 11:33:27 +08:00
data() {
2018-03-26 23:05:29 +08:00
return {
show: false,
2019-01-12 11:33:27 +08:00
};
2018-03-26 23:05:29 +08:00
},
2019-01-12 11:33:27 +08:00
render() {
2018-04-01 12:52:27 +08:00
const columns = [
{ title: 'title1', dataIndex: 'a', key: 'a', width: 100, fixed: 'left' },
{ title: 'title2', dataIndex: 'b', key: 'b', width: 100, fixed: 'left' },
{ title: 'title3', dataIndex: 'c', key: 'c' },
{ title: 'title4', dataIndex: 'b', key: 'd' },
{ title: 'title5', dataIndex: 'b', key: 'e' },
2019-01-12 11:33:27 +08:00
{
title: 'title6',
dataIndex: 'b',
key: 'f',
customRender: () => <div style={{ height: '40px', lineHeight: '40px' }}>我很高</div>,
},
2018-04-01 12:52:27 +08:00
{ title: 'title7', dataIndex: 'b', key: 'g' },
{ title: 'title8', dataIndex: 'b', key: 'h' },
{ title: 'title9', dataIndex: 'b', key: 'i' },
{ title: 'title10', dataIndex: 'b', key: 'j' },
{ title: 'title11', dataIndex: 'b', key: 'k' },
{ title: 'title12', dataIndex: 'b', key: 'l', width: 100, fixed: 'right' },
2019-01-12 11:33:27 +08:00
];
2018-03-26 23:05:29 +08:00
return (
<div style={{ width: '800px' }}>
<h2>Fixed columns</h2>
2019-01-12 11:33:27 +08:00
<button
onClick={() => {
this.show = true;
}}
>
show Table
</button>
{this.show ? (
<Table
columns={columns}
expandedRowRender={record => record.title}
expandIconAsCell
scroll={{ x: 1200 }}
data={data}
/>
) : null}
2018-03-26 23:05:29 +08:00
</div>
2019-01-12 11:33:27 +08:00
);
2018-03-26 23:05:29 +08:00
},
2019-01-12 11:33:27 +08:00
};