bee-table/demo/demolist/Demo1601.js

74 lines
1.6 KiB
JavaScript
Raw Normal View History

2018-12-21 09:58:52 +08:00
/**
2019-03-20 17:44:05 +08:00
* @title 表格+分页
2019-04-18 10:50:38 +08:00
* @parent 分页 Pagination
2019-03-20 17:44:05 +08:00
* @description 点击分页联动表格
*/
2018-12-21 09:58:52 +08:00
2019-03-20 17:44:05 +08:00
import React, { Component } from "react";
import {Pagination} from "tinper-bee";
2018-12-21 09:58:52 +08:00
2019-03-20 17:44:05 +08:00
import Table from "../../src";
2018-12-21 09:58:52 +08:00
2019-03-20 17:44:05 +08:00
const columns8 = [
{ title: "姓名", dataIndex: "a", key: "a", width: 100 },
{ id: "123", title: "性别", dataIndex: "b", key: "b", width: 100 },
{ title: "年龄", dataIndex: "c", key: "c", width: 200 },
2018-12-21 09:58:52 +08:00
{
title: "武功级别",
dataIndex: "d",
2019-03-20 17:44:05 +08:00
key: "d"
2018-12-21 09:58:52 +08:00
}
];
2019-03-20 17:44:05 +08:00
const pageData = {
1: [
{ a: "杨过", b: "男", c: 30, d: "内行", key: "2" },
{ a: "令狐冲", b: "男", c: 41, d: "大侠", key: "1" },
{ a: "郭靖", b: "男", c: 25, d: "大侠", key: "3" }
],
2: [
{ a: "芙蓉姐姐", b: "女", c: 23, d: "大侠", key: "1" },
{ a: "芙蓉妹妹", b: "女", c: 23, d: "内行", key: "2" }
]
};
2018-12-21 09:58:52 +08:00
2019-03-20 17:44:05 +08:00
class Demo8 extends Component {
2018-12-21 09:58:52 +08:00
constructor(props) {
super(props);
this.state = {
2019-03-20 17:44:05 +08:00
data: pageData[1],
activePage: 1
};
2018-12-21 09:58:52 +08:00
}
2019-03-20 17:44:05 +08:00
handleSelect(eventKey) {
this.setState({
data: pageData[eventKey],
activePage: eventKey
2018-12-21 09:58:52 +08:00
});
}
render() {
2019-03-20 17:44:05 +08:00
return (
<div className="demo8">
<Table columns={columns8} data={this.state.data} />
<Pagination
first
last
prev
next
maxButtons={5}
boundaryLinks
activePage={this.state.activePage}
onSelect={this.handleSelect.bind(this)}
onDataNumSelect={this.dataNumSelect}
showJump={true}
total={100}
dataNum={2}
/>
</div>
);
2018-12-21 09:58:52 +08:00
}
}
2019-03-20 17:44:05 +08:00
export default Demo8;