bee-table/demo/demolist/Demo6.js

66 lines
1.2 KiB
JavaScript
Raw Normal View History

2018-12-21 09:58:52 +08:00
/**
2019-03-20 17:44:05 +08:00
* @title 列排序
* @description column中增加sorter: (a, b) => a.c - b.c 这里的a,b代表前后两个数据c代表比较当前对象的字段名称
2018-12-21 09:58:52 +08:00
*
*/
import React, { Component } from 'react';
2019-03-20 17:44:05 +08:00
import {Icon} from "tinper-bee";
2018-12-21 09:58:52 +08:00
import Table from '../../src';
2019-03-20 17:44:05 +08:00
import sort from "../../src/lib/sort.js";
2018-12-21 09:58:52 +08:00
2019-03-20 17:44:05 +08:00
let ComplexTable = sort(Table, Icon);
const columns11 = [
2018-12-21 09:58:52 +08:00
{
2019-03-20 17:44:05 +08:00
title: "名字",
dataIndex: "a",
key: "a",
width: 100
2018-12-21 09:58:52 +08:00
},
{
2019-03-20 17:44:05 +08:00
title: "性别",
dataIndex: "b",
key: "b",
width: 100
2018-12-21 09:58:52 +08:00
},
{
2019-03-20 17:44:05 +08:00
title: "年龄",
dataIndex: "c",
key: "c",
width: 200,
sorter: (a, b) => a.c - b.c
2018-12-21 09:58:52 +08:00
},
{
2019-03-20 17:44:05 +08:00
title: "武功级别",
dataIndex: "d",
key: "d"
2018-12-21 09:58:52 +08:00
}
];
2019-03-20 17:44:05 +08:00
const data11 = [
{ a: "杨过", b: "男", c: 30,d:'内行', key: "2" },
{ a: "令狐冲", b: "男", c: 41,d:'大侠', key: "1" },
{ a: "郭靖", b: "男", c: 25,d:'大侠', key: "3" }
];
const defaultProps11 = {
prefixCls: "bee-table"
};
class Demo11 extends Component {
constructor(props) {
super(props);
this.state = {
sortOrder: "",
data: data11
};
}
2018-12-21 09:58:52 +08:00
render() {
2019-03-20 17:44:05 +08:00
return <ComplexTable columns={columns11} data={this.state.data} />;
2018-12-21 09:58:52 +08:00
}
}
2019-03-20 17:44:05 +08:00
Demo11.defaultProps = defaultProps11;
2018-12-21 09:58:52 +08:00
2019-03-20 17:44:05 +08:00
export default Demo11;