bee-table7/demo/demolist/Demo0902.js

83 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 列操作-排序 Sort
2019-04-19 15:46:04 +08:00
* @description 可在控制台中查看序列化后的参数字符串将参数传递给后端即可进行列排序
2019-03-20 17:44:05 +08:00
*/
2018-12-21 09:58:52 +08:00
2019-03-20 17:44:05 +08:00
import React, { Component } from 'react';
import {Icon} from "tinper-bee";
import Table from '../../src';
import sort from "../../src/lib/sort.js";
let ComplexTable = sort(Table, Icon);
const columns11 = [
{
title: "名字",
dataIndex: "a",
key: "a",
width: 100
},
{
title: "性别",
dataIndex: "b",
key: "b",
width: 100
},
{
title: "年龄",
dataIndex: "c",
key: "c",
width: 200,
sorter: (a, b) => a.c - b.c
},
2018-12-21 09:58:52 +08:00
{
title: "武功级别",
dataIndex: "d",
key: "d"
2019-03-20 17:44:05 +08:00
},
{
title: "分数",
dataIndex: "e",
key: "e",
sorter: (a, b) => a.c - b.c
},
2018-12-21 09:58:52 +08:00
];
2019-03-20 17:44:05 +08:00
const data11 = [
{ a: "杨过", b: "男", c: 30,d:'内行', e:139,key: "2" },
{ a: "令狐冲", b: "男", c: 41,d:'大侠', e:109, key: "1" },
{ a: "郭靖", b: "男", c: 25,d:'大侠', e:159, key: "3" }
2018-12-21 09:58:52 +08:00
];
2019-03-20 17:44:05 +08:00
const defaultProps = {
prefixCls: "bee-table"
};
class Demo28 extends Component {
2018-12-21 09:58:52 +08:00
constructor(props) {
super(props);
this.state = {
2019-03-20 17:44:05 +08:00
sortOrder: "",
data: data11
2018-12-21 09:58:52 +08:00
};
}
2019-03-20 17:44:05 +08:00
/**
* 后端获取数据
*/
sortFun = (sortParam)=>{
console.info(sortParam);
//将参数传递给后端排序
}
2018-12-21 09:58:52 +08:00
render() {
2019-03-20 17:44:05 +08:00
let sortObj = {
mode:'multiple',
backSource:true,
sortFun:this.sortFun
}
return <ComplexTable columns={columns11} data={this.state.data} sort={sortObj}/>;
2018-12-21 09:58:52 +08:00
}
}
2019-03-20 17:44:05 +08:00
Demo28.defaultProps = defaultProps;
2018-12-21 09:58:52 +08:00
2019-03-20 17:44:05 +08:00
export default Demo28;