add docs
This commit is contained in:
parent
363d8ca0b0
commit
d1129aff4c
48
README.md
48
README.md
|
@ -8,11 +8,6 @@
|
||||||
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/tinper-bee/bee-table.svg)](http://isitmaintained.com/project/tinper-bee/bee-table "Average time to resolve an issue")
|
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/tinper-bee/bee-table.svg)](http://isitmaintained.com/project/tinper-bee/bee-table "Average time to resolve an issue")
|
||||||
[![Percentage of issues still open](http://isitmaintained.com/badge/open/tinper-bee/bee-table.svg)](http://isitmaintained.com/project/tinper-bee/bee-table "Percentage of issues still open")
|
[![Percentage of issues still open](http://isitmaintained.com/badge/open/tinper-bee/bee-table.svg)](http://isitmaintained.com/project/tinper-bee/bee-table "Percentage of issues still open")
|
||||||
|
|
||||||
## Browser Support
|
|
||||||
|
|
||||||
|![IE](https://raw.github.com/alrra/browser-logos/master/internet-explorer/internet-explorer_48x48.png) | ![Chrome](https://raw.github.com/alrra/browser-logos/master/chrome/chrome_48x48.png) | ![Firefox](https://raw.github.com/alrra/browser-logos/master/firefox/firefox_48x48.png) | ![Opera](https://raw.github.com/alrra/browser-logos/master/opera/opera_48x48.png) | ![Safari](https://raw.github.com/alrra/browser-logos/master/safari/safari_48x48.png)|
|
|
||||||
| --- | --- | --- | --- | --- |
|
|
||||||
| IE 9+ ✔ | Chrome 31.0+ ✔ | Firefox 31.0+ ✔ | Opera 30.0+ ✔ | Safari 7.0+ ✔ |
|
|
||||||
|
|
||||||
|
|
||||||
react bee-table component for tinper-bee
|
react bee-table component for tinper-bee
|
||||||
|
@ -58,8 +53,49 @@ class Demo extends Component {
|
||||||
|
|
||||||
## API
|
## API
|
||||||
|
|
||||||
|
### Table
|
||||||
|
|
||||||
|参数|说明|类型|默认值|
|
|参数|说明|类型|默认值|
|
||||||
|:--|:---:|:--:|---:|
|
|:--|:---|:--|:---|
|
||||||
|
|data|传入的表格数据|array|[]|
|
||||||
|
|columns|列的配置表,具体配置见下表|array|-|
|
||||||
|
|defaultExpandAllRows|默认是否展开所有行|bool|false|
|
||||||
|
|expandedRowKeys|展开的行,控制属性|array|-|
|
||||||
|
|defaultExpandedRowKeys|初始扩展行键|array|[]|
|
||||||
|
|useFixedHeader|是否使用固定表头|bool|false|
|
||||||
|
|bodyStyle|添加到tablebody上的style|object|{}|
|
||||||
|
|style|添加到table上的style|object|{}|
|
||||||
|
|rowKey|如果rowKey是字符串,`record [rowKey]`将被用作键。如果rowKey是function,`rowKey(record)'的返回值将被用作键。| string or Function(record):string|'key'|
|
||||||
|
|rowClassName|获取行的classname|Function(record, index, indent):string|() => ''|
|
||||||
|
|expandedRowClassName|获取展开行的className|Function(recode, index, indent):string|() => ''|
|
||||||
|
|onExpand|展开行时的钩子函数|Function(expanded, record)|() => ''|
|
||||||
|
|onExpandedRowsChange|函数在扩展行更改时调用|Function(expandedRows)|() => ''|
|
||||||
|
|indentSize|indentSize为每个级别的data.i.children,更好地使用column.width指定|number|15|
|
||||||
|
|onRowClick|行的点击事件钩子函数|Function(record, index)|() => ''|
|
||||||
|
|onRowDoubleClick|行的双击事件钩子函数|Function(record, index)|() => ''|
|
||||||
|
|expandIconAsCell|是否将expandIcon作为单元格|bool|false|
|
||||||
|
|expandIconColumnIndex|expandIcon的索引,当expandIconAsCell为false时,将插入哪个列|number|0|
|
||||||
|
|showHeader|是否显示表头|bool|true|
|
||||||
|
|title|表格标题|function|-|
|
||||||
|
|footer|表格尾部|function|-|
|
||||||
|
|emptyText|无数据时显示的内容|function|() => 'No Data'|
|
||||||
|
|scroll|横向或纵向支持滚动,也可用于指定滚动区域的宽高度:{{ x: true, y: 300 }}|object|{}|
|
||||||
|
|rowRef|获取行的ref|Function(record, index, indent):string|() => null|
|
||||||
|
|getBodyWrapper|添加对table body的包装|Function(body)|body => body|
|
||||||
|
|
||||||
|
### Column
|
||||||
|
|
||||||
|
|参数|说明|类型|默认值|
|
||||||
|
|:--|:---|:--|:---|
|
||||||
|
|key|列的键|string|-|
|
||||||
|
|className|传入列的classname|String |-|
|
||||||
|
|colSpan|该列的colSpan|Number|-|
|
||||||
|
|title|列的标题|node|-|
|
||||||
|
|dataIndex| 显示数据记录的字段|String|-|
|
||||||
|
|width|宽度的特定比例根据列的宽度计算|String/Number|-|
|
||||||
|
|fixed| 当表水平滚动时,此列将被固定:true或'left'或'right'| true/'left'/'right'|-|
|
||||||
|
|render|cell的render函数有三个参数:这个单元格的文本,这行的记录,这行的索引,它返回一个对象:{children:value,props:{colSpan:1,rowSpan:1}} ==>'children'是这个单元格的文本,props是这个单元格的一些设置|-|
|
||||||
|
|onCellClick|单击列的单元格时调用|Function(row, event)|-|
|
||||||
|
|
||||||
#### 开发调试
|
#### 开发调试
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @title 更灵活的表格
|
||||||
|
* @description 手写表格的头组件来达到更灵活的配置表格
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
const { ColumnGroup, Column } = Table;
|
||||||
|
|
||||||
|
const data3 = [
|
||||||
|
{ a: '北京', b: '北京', c: '250', d: 2, key: '1' },
|
||||||
|
];
|
||||||
|
|
||||||
|
class Demo3 extends Component {
|
||||||
|
render () {
|
||||||
|
return (
|
||||||
|
|
||||||
|
<Table data={data3}>
|
||||||
|
<ColumnGroup title="地址">
|
||||||
|
<Column
|
||||||
|
title="省"
|
||||||
|
dataIndex="a"
|
||||||
|
key="a"
|
||||||
|
width={100}
|
||||||
|
/>
|
||||||
|
<Column
|
||||||
|
id="123"
|
||||||
|
title="市"
|
||||||
|
dataIndex="b"
|
||||||
|
key="b"
|
||||||
|
width={100}
|
||||||
|
/>
|
||||||
|
</ColumnGroup>
|
||||||
|
<Column
|
||||||
|
title="数量"
|
||||||
|
dataIndex="c"
|
||||||
|
key="c"
|
||||||
|
width={200}
|
||||||
|
/>
|
||||||
|
<Column
|
||||||
|
title="操作"
|
||||||
|
dataIndex=""
|
||||||
|
key="d"
|
||||||
|
render={(text, record, index) => {
|
||||||
|
return (
|
||||||
|
<Button size="sm" colors="info" style={{ minWidth: 50 }}>增加</Button>
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Table>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because one or more lines are too long
49
docs/api.md
49
docs/api.md
|
@ -1,5 +1,52 @@
|
||||||
# Table
|
# Table
|
||||||
|
|
||||||
|
表格是以结构化的方式来展示大量的信息最佳方法,使信息更易于阅读与理解。
|
||||||
|
表格轻易就能用简洁和易读的方式来组织数据。它们可用于保存和展示大量的数据,小量的信息,静态数据以及不断地变动的数据。
|
||||||
|
|
||||||
## 代码演示
|
## 代码演示
|
||||||
|
|
||||||
## API
|
## API
|
||||||
|
|
||||||
|
### Table
|
||||||
|
|
||||||
|参数|说明|类型|默认值|
|
|参数|说明|类型|默认值|
|
||||||
|:---|:-----|:----|:------|
|
|:--|:---|:--|:---|
|
||||||
|
|data|传入的表格数据|array|[]|
|
||||||
|
|columns|列的配置表,具体配置见下表|array|-|
|
||||||
|
|defaultExpandAllRows|默认是否展开所有行|bool|false|
|
||||||
|
|expandedRowKeys|展开的行,控制属性|array|-|
|
||||||
|
|defaultExpandedRowKeys|初始扩展行键|array|[]|
|
||||||
|
|useFixedHeader|是否使用固定表头|bool|false|
|
||||||
|
|bodyStyle|添加到tablebody上的style|object|{}|
|
||||||
|
|style|添加到table上的style|object|{}|
|
||||||
|
|rowKey|如果rowKey是字符串,`record [rowKey]`将被用作键。如果rowKey是function,`rowKey(record)'的返回值将被用作键。| string or Function(record):string|'key'|
|
||||||
|
|rowClassName|获取行的classname|Function(record, index, indent):string|() => ''|
|
||||||
|
|expandedRowClassName|获取展开行的className|Function(recode, index, indent):string|() => ''|
|
||||||
|
|onExpand|展开行时的钩子函数|Function(expanded, record)|() => ''|
|
||||||
|
|onExpandedRowsChange|函数在扩展行更改时调用|Function(expandedRows)|() => ''|
|
||||||
|
|indentSize|indentSize为每个级别的data.i.children,更好地使用column.width指定|number|15|
|
||||||
|
|onRowClick|行的点击事件钩子函数|Function(record, index)|() => ''|
|
||||||
|
|onRowDoubleClick|行的双击事件钩子函数|Function(record, index)|() => ''|
|
||||||
|
|expandIconAsCell|是否将expandIcon作为单元格|bool|false|
|
||||||
|
|expandIconColumnIndex|expandIcon的索引,当expandIconAsCell为false时,将插入哪个列|number|0|
|
||||||
|
|showHeader|是否显示表头|bool|true|
|
||||||
|
|title|表格标题|function|-|
|
||||||
|
|footer|表格尾部|function|-|
|
||||||
|
|emptyText|无数据时显示的内容|function|() => 'No Data'|
|
||||||
|
|scroll|横向或纵向支持滚动,也可用于指定滚动区域的宽高度:{{ x: true, y: 300 }}|object|{}|
|
||||||
|
|rowRef|获取行的ref|Function(record, index, indent):string|() => null|
|
||||||
|
|getBodyWrapper|添加对table body的包装|Function(body)|body => body|
|
||||||
|
|
||||||
|
### Column
|
||||||
|
|
||||||
|
|参数|说明|类型|默认值|
|
||||||
|
|:--|:---|:--|:---|
|
||||||
|
|key|列的键|string|-|
|
||||||
|
|className|传入列的classname|String |-|
|
||||||
|
|colSpan|该列的colSpan|Number|-|
|
||||||
|
|title|列的标题|node|-|
|
||||||
|
|dataIndex| 显示数据记录的字段|String|-|
|
||||||
|
|width|宽度的特定比例根据列的宽度计算|String/Number|-|
|
||||||
|
|fixed| 当表水平滚动时,此列将被固定:true或'left'或'right'| true/'left'/'right'|-|
|
||||||
|
|render|cell的render函数有三个参数:这个单元格的文本,这行的记录,这行的索引,它返回一个对象:{children:value,props:{colSpan:1,rowSpan:1}} ==>'children'是这个单元格的文本,props是这个单元格的一些设置|-|
|
||||||
|
|onCellClick|单击列的单元格时调用|Function(row, event)|-|
|
||||||
|
|
|
@ -221,7 +221,7 @@ class Table extends Component{
|
||||||
|
|
||||||
if (expandIconAsCell && fixed !== 'right') {
|
if (expandIconAsCell && fixed !== 'right') {
|
||||||
rows[0].unshift({
|
rows[0].unshift({
|
||||||
key: 'rc-table-expandIconAsCell',
|
key: 'u-table-expandIconAsCell',
|
||||||
className: `${clsPrefix}-expand-icon-th`,
|
className: `${clsPrefix}-expand-icon-th`,
|
||||||
title: '',
|
title: '',
|
||||||
rowSpan: rows.length,
|
rowSpan: rows.length,
|
||||||
|
@ -411,7 +411,7 @@ class Table extends Component{
|
||||||
cols.push(
|
cols.push(
|
||||||
<col
|
<col
|
||||||
className={`${this.props.clsPrefix}-expand-icon-col`}
|
className={`${this.props.clsPrefix}-expand-icon-col`}
|
||||||
key="rc-table-expand-icon-col"
|
key="u-table-expand-icon-col"
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue