bee-table/demo/demolist/Demo30.js

110 lines
2.4 KiB
JavaScript
Raw Normal View History

2018-12-18 13:59:48 +08:00
/**
*
* @title 大数据加载
* Tooltip
* @description
*/
import React, { Component } from "react";
import Tooltip from "bee-tooltip";
import Table from "../../src";
import BigData from "../../src/lib/bigData";
const BigDataTable = BigData(Table);
2019-01-22 11:05:42 +08:00
const columns = [
{
title:'序号',
dataIndex:'index',
width:'50',
render:(text,record,index)=>{
return index
},
fixed:'left'
},
{
title: "用户名", dataIndex: "a", key: "a", width: 580, className: "rowClassName",
render: (text, record, index) => {
return (
<Tooltip inverse overlay={text}>
<span tootip={text} style={{
display: "inline-block",
width: "80px",
textOverflow: "ellipsis",
overflow: "hidden",
whiteSpace: "nowrap",
verticalAlign: "middle",
}}>{text}</span>
</Tooltip>
);
}
},
{ id: "123", title: "性别", dataIndex: "b", key: "b", width: 80},
{ title: "年龄", dataIndex: "c", key: "c", width: 200 },
{
title: "操作",
dataIndex: "d",
key: "d",
fixed:'right',
render(text, record, index) {
return (
<div style={{ position: 'relative' }} title={text} >
<a
href="javascript:;"
tooltip={text}
onClick={() => {
alert('这是第' + index + '列,内容为:' + text);
}}
>
一些操作
</a>
</div>
);
}
}
];
2018-12-18 13:59:48 +08:00
2019-02-19 09:30:18 +08:00
const data = [ ...new Array(20) ].map((e, i) => {
2018-12-18 15:42:31 +08:00
const rs = { a: i + 'a', b: i + 'b', c: i + 'c', d: i + 'd', key: i };
if(i%3==0){
2018-12-20 18:07:30 +08:00
rs.b = '女';
2018-12-18 15:42:31 +08:00
}
return rs;
2018-12-18 13:59:48 +08:00
})
2018-12-26 15:02:34 +08:00
class Demo30 extends Component {
2019-01-22 11:05:42 +08:00
2018-12-18 13:59:48 +08:00
constructor(props) {
super(props);
this.state = {
data: data,
2019-01-22 11:05:42 +08:00
selectedRowIndex: 0
2018-12-18 13:59:48 +08:00
}
}
2019-02-19 09:30:18 +08:00
add=()=>{
let {data} = this.state;
const len =data.length;
data.push({a: len + 'a', b: len+ 'b', c: len + 'c', d: len + 'd', key: len });
this.setState({
data
});
}
2018-12-18 13:59:48 +08:00
render() {
return (
2019-02-19 09:30:18 +08:00
<div>
<button onClick={this.add}>new</button>
2018-12-18 13:59:48 +08:00
<BigDataTable
2019-01-22 11:05:42 +08:00
columns={columns}
2018-12-18 13:59:48 +08:00
data={data}
2018-12-22 12:04:03 +08:00
scroll={{y:300}}
2018-12-20 19:37:07 +08:00
height={40}
2018-12-18 13:59:48 +08:00
onRowClick={(record, index, indent) => {
console.log('currentIndex--'+index);
2018-12-18 13:59:48 +08:00
}}
/>
2019-02-19 09:30:18 +08:00
</div>
2018-12-18 13:59:48 +08:00
);
}
}
2019-01-22 11:05:42 +08:00
export default Demo30;