bee-table7/demo/demolist/Demo1106.js

71 lines
1.8 KiB
JavaScript
Raw Normal View History

2018-12-21 09:58:52 +08:00
/**
*
2019-04-19 15:46:04 +08:00
* @title 自定义行高
2019-04-18 10:50:38 +08:00
* @parent 扩展行 Expanded Row
2019-04-22 15:44:14 +08:00
* @description 设置`height`属性自定义表体行高设置`headerHeight`属性自定义表头高度
2018-12-21 09:58:52 +08:00
*/
2019-03-20 17:44:05 +08:00
import React, { Component } from "react";
2019-04-18 10:50:38 +08:00
import {Button,Tooltip} from "tinper-bee";
2019-03-20 17:44:05 +08:00
import Table from "../../src";
2018-12-21 09:58:52 +08:00
2019-04-18 10:50:38 +08:00
const columns = [
2019-04-22 15:44:14 +08:00
{ title: "员工编号", dataIndex: "a", key: "a", width: 300, className: "rowClassName"},
{ title: "员工姓名", dataIndex: "b", key: "b", width: 500 },
{ title: "性别", dataIndex: "c", key: "c", width: 500 },
{ title: "部门", dataIndex: "d", key: "d", width: 200 }
2019-04-18 10:50:38 +08:00
];
const data = [
2019-04-22 15:44:14 +08:00
{ a: "ASVAL_201903280005", b: "小张", c: "男", d: "财务二科", key: "1" },
{ a: "ASVAL_201903200004", b: "小明", c: "男", d: "财务一科", key: "2" },
{ a: "ASVAL_201903120002", b: "小红", c: "女", d: "财务一科", key: "3" }
2019-04-18 10:50:38 +08:00
];
2019-04-19 15:46:04 +08:00
class Demo1 extends Component {
2019-04-18 10:50:38 +08:00
constructor(props) {
super(props);
this.state = {
data: data,
selectedRowIndex: 0
2019-03-20 17:44:05 +08:00
}
2019-04-18 10:50:38 +08:00
}
handleClick = () => {
console.log('这是第' , this.currentIndex , '行');
console.log('内容:' , this.currentRecord);
}
2018-12-21 09:58:52 +08:00
2019-04-18 10:50:38 +08:00
onRowHover=(index,record)=>{
this.currentIndex = index;
this.currentRecord = record;
}
getHoverContent=()=>{
return <div className="opt-btns"><Button size="sm" onClick={this.handleClick}>一些操作</Button> </div>
}
2018-12-21 09:58:52 +08:00
render() {
return (
2019-04-18 10:50:38 +08:00
<Table
columns={columns}
data={data}
parentNodeId='parent'
2019-04-19 15:46:04 +08:00
height={40}
headerHeight={40}
2019-04-18 10:50:38 +08:00
hoverContent={this.getHoverContent}
onRowHover={this.onRowHover}
2019-04-19 15:46:04 +08:00
onRowClick={(record, index, indent) => {
this.setState({
selectedRowIndex: index
});
}}
2019-04-18 10:50:38 +08:00
/>
2019-04-19 15:46:04 +08:00
2018-12-21 09:58:52 +08:00
);
}
}
2019-04-19 15:46:04 +08:00
export default Demo1;