bee-table7/demo/demolist/Demo0402.js

128 lines
2.7 KiB
JavaScript
Raw Normal View History

2019-04-15 20:14:02 +08:00
/**
*
2019-11-25 17:58:02 +08:00
* @title 多列表头
2019-04-18 10:50:38 +08:00
* @parent 列渲染 Custom Render
2019-04-15 20:14:02 +08:00
* @description columns[n] 可以内嵌 children以渲染分组表头
* 自定义表头高度需要传headerHeight修改th的padding top和bottom置为0否则会有影响
2019-11-05 16:39:49 +08:00
* 多列表头拖拽的时候,原则只拖拽叶子节点的表头
2019-04-23 20:11:38 +08:00
* demo0402
2019-04-15 20:14:02 +08:00
*/
import React, { Component } from "react";
import Table from "../../src";
2019-11-05 16:30:55 +08:00
import dragColumn from '../../src/lib/dragColumn';
2019-04-15 20:14:02 +08:00
const columns = [
{
2019-11-25 17:58:02 +08:00
title: "姓名",
2019-04-15 20:14:02 +08:00
dataIndex: "name",
key: "name",
width: 100,
fixed: "left"
},
{
2019-11-25 17:58:02 +08:00
title: "个人信息",
2019-04-15 20:14:02 +08:00
width:600,
children: [
{
2019-11-25 17:58:02 +08:00
title: "年龄",
2019-04-15 20:14:02 +08:00
dataIndex: "age",
key: "age",
width: 200
},
{
2019-11-25 17:58:02 +08:00
title: "地址",
2019-04-15 20:14:02 +08:00
children: [
{
2019-11-25 17:58:02 +08:00
title: "街道",
2019-04-15 20:14:02 +08:00
dataIndex: "street",
key: "street",
width: 200
},
{
2019-11-25 17:58:02 +08:00
title: "单元",
2019-04-15 20:14:02 +08:00
children: [
{
2019-11-25 17:58:02 +08:00
title: "楼号",
2019-04-15 20:14:02 +08:00
dataIndex: "building",
key: "building",
width: 100
},
{
2019-11-25 17:58:02 +08:00
title: "门户",
2019-04-15 20:14:02 +08:00
dataIndex: "number",
key: "number",
width: 100
}
]
}
]
}
]
},
{
2019-11-25 17:58:02 +08:00
title: "公司信息",
2019-04-15 20:14:02 +08:00
width:400,
children: [
{
2019-11-25 17:58:02 +08:00
title: "公司地址",
2019-04-15 20:14:02 +08:00
dataIndex: "companyAddress",
key: "companyAddress",
width:200,
},
{
2019-11-25 17:58:02 +08:00
title: "公司名称",
2019-04-15 20:14:02 +08:00
dataIndex: "companyName",
key: "companyName",
width:200,
}
]
},
{
2019-11-25 17:58:02 +08:00
title: "性别",
2019-04-15 20:14:02 +08:00
dataIndex: "gender",
key: "gender",
width: 60,
fixed: "right"
}
];
const data = [];
for (let i = 0; i < 20; i++) {
data.push({
key: i,
name: "John Brown",
age: i + 1,
street: "Lake Park",
building: "C",
number: 2035,
2019-11-25 17:58:02 +08:00
companyAddress: "北清路 68 号",
companyName: "用友",
gender: "男"
2019-04-15 20:14:02 +08:00
});
}
2019-11-05 16:30:55 +08:00
const DragColumnTable = dragColumn(Table);
2020-07-16 09:31:03 +08:00
class Demo12 extends Component {
2019-04-15 20:14:02 +08:00
render() {
return (
2019-11-05 16:30:55 +08:00
<DragColumnTable
2019-04-16 13:35:25 +08:00
className={'demo32'}
2019-04-15 20:14:02 +08:00
columns={columns}
data={data}
headerHeight={40} //自定义表头高度
bordered
2019-11-05 16:30:55 +08:00
dragborder={true}
onDropBorder ={(e,width)=>{
console.log(width+"--调整列宽后触发事件",e.target);
}}
2019-04-15 20:14:02 +08:00
scroll={{ y: 240 }}
/>
);
}
}
2020-07-16 09:31:03 +08:00
export default Demo12;