bee-table/demo/demolist/Demo01.js

79 lines
1.8 KiB
JavaScript
Raw Normal View History

2018-12-21 09:58:52 +08:00
/**
*
2019-04-15 20:14:02 +08:00
* @title 基本表格
2018-12-21 09:58:52 +08:00
* Tooltip
2019-04-16 13:35:25 +08:00
* @description 鼠标hover行时呼出操作按钮
2018-12-21 09:58:52 +08:00
*/
import React, { Component } from "react";
2019-04-15 20:14:02 +08:00
import {Button,Tooltip} from "tinper-bee";
2018-12-21 09:58:52 +08:00
import Table from "../../src";
const columns = [
{
2019-02-25 16:44:05 +08:00
title: "用户名", dataIndex: "a", key: "a", width: 300, className: "rowClassName",
fixed:'left',
2018-12-21 09:58:52 +08:00
render: (text, record, index) => {
return (
<Tooltip inverse overlay={text}>
<span tootip={text} style={{
display: "inline-block",
width: "60px",
textOverflow: "ellipsis",
overflow: "hidden",
whiteSpace: "nowrap",
verticalAlign: "middle",
}}>{text}</span>
</Tooltip>
);
}
},
2019-02-25 16:44:05 +08:00
{ id: "123", title: "性别", dataIndex: "b", key: "b", width: 500},
2019-04-15 20:14:02 +08:00
{ title: "年龄", dataIndex: "c", key: "c", width: 200 }
2018-12-21 09:58:52 +08:00
];
const data = [
2019-04-15 20:14:02 +08:00
{ a: "令狐冲", b: "男", c: 41, key: "1" },
{ a: "杨过叔叔的女儿黄蓉", b: "男", c: 67, key: "2" },
{ a: "郭靖", b: "男", c: 25, key: "3" }
2018-12-21 09:58:52 +08:00
];
2019-04-16 13:35:25 +08:00
class Demo01 extends Component {
2018-12-21 09:58:52 +08:00
constructor(props) {
super(props);
this.state = {
2019-04-16 13:35:25 +08:00
data: data
2018-12-21 09:58:52 +08:00
}
}
2019-04-15 20:14:02 +08:00
handleClick = () => {
console.log('这是第' , this.currentIndex , '行');
console.log('内容:' , this.currentRecord);
}
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 (
<Table
columns={columns}
data={data}
parentNodeId='parent'
height={40}
headerHeight={40}
2019-04-15 20:14:02 +08:00
hoverContent={this.getHoverContent}
onRowHover={this.onRowHover}
2018-12-21 09:58:52 +08:00
/>
);
}
}
2019-04-16 13:35:25 +08:00
export default Demo01;