bee-table/demo/demolist/Demo1103.js

60 lines
1.5 KiB
JavaScript

/**
*
* @title 选中行颜色、自定义表格标题和表尾
* @parent 扩展行 Expanded Row
* @description 选中行的样式可自定义
*/
import React, { Component } from "react";
import {Button,Tooltip,} from "tinper-bee";
import Table from "../../src";
const columns = [
{ title: "用户名", dataIndex: "a", key: "a", width:80 , className:"rowClassName"},
{ id: "123", title: "性别", dataIndex: "b", key: "b", width: 100 },
{ title: "年龄", dataIndex: "c", key: "c", width: 200 },
];
const data = [
{ a: "令狐冲", b: "男", c: 41, key: "1" },
{ a: "黄蓉", b: "男", c: 67, key: "2" },
{ a: "郭靖", b: "男", c: 25, key: "3" }
];
class Demo26 extends Component {
constructor(props){
super(props);
this.state = {
data: data,
selectedRowIndex: 0
}
}
render() {
return (
<Table
columns={columns}
data={data}
rowClassName={(record,index,indent)=>{
if (this.state.selectedRowIndex == index) {
return 'selected';
} else {
return '';
}
}}
onRowClick={(record,index,indent)=>{
this.setState({
selectedRowIndex: index
});
}}
title={currentData => <div>标题: 这是一个标题</div>}
footer={currentData => <div>表尾: 我是小尾巴</div>}
/>
);
}
}
export default Demo26;