From 32ae4289dbc44adf79f8618024eb96fb4f06b732 Mon Sep 17 00:00:00 2001 From: 2betop Date: Wed, 23 Mar 2016 04:03:12 +0000 Subject: [PATCH] based on https://github.com/fis-components/components/blob/master/packages/rc-table.json --- README.md | 36 ++++++++++++++++++++++++++++++------ component.json | 2 +- lib/Table.js | 26 +++++++++++++++++++++----- 3 files changed, 52 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 5033a02..570b6b6 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,12 @@ var table = React.render( false whether use separator table for header. better set width for columns + + scroll + Object + {x: false, y: false} + whether table can be scroll in x/y direction, `y` can be a number that indicated the height of table body + expandIconAsCell Boolean @@ -186,17 +192,29 @@ var table = React.render( handle rowClick action, index means the index of current row among fatherElement[childrenColumnName] + + columnsPageSize + Number + 5 + pageSize of columns. (Deprecated, use fixed columns) + columnsPageRange Array - columns index range need paging, like [2,10] + columns index range need paging, like [2,10]. (Deprecated, use column.fixed) - columnsPageSize - Number - 5 - pageSize of columns + showHeader + Boolean + true + whether table head is shown + + + footer + Function(currentData) + + table footer render function columns @@ -242,7 +260,13 @@ var table = React.render( width String|Number - he width of the specific proportion calculation according to the width of the columns + width of the specific proportion calculation according to the width of the columns + + + fixed + String|Boolean + + this column will be fixed when table scroll horizontally: true or 'left' or 'right' render diff --git a/component.json b/component.json index 86614cc..1378545 100644 --- a/component.json +++ b/component.json @@ -5,7 +5,7 @@ "main": "./lib/index", "tag": "master", "reposType": "npm", - "version": "3.10.1", + "version": "3.11.1", "dependencies": { "object-assign": "^4.0.1" } diff --git a/lib/Table.js b/lib/Table.js index b010ce2..eafc6e7 100644 --- a/lib/Table.js +++ b/lib/Table.js @@ -40,7 +40,9 @@ var Table = _react2['default'].createClass({ onRowClick: _react2['default'].PropTypes.func, columnsPageRange: _react2['default'].PropTypes.array, columnsPageSize: _react2['default'].PropTypes.number, - expandIconColumnIndex: _react2['default'].PropTypes.number + expandIconColumnIndex: _react2['default'].PropTypes.number, + showHeader: _react2['default'].PropTypes.bool, + footer: _react2['default'].PropTypes.func }, getDefaultProps: function getDefaultProps() { @@ -66,7 +68,8 @@ var Table = _react2['default'].createClass({ childrenColumnName: 'children', indentSize: 15, columnsPageSize: 5, - expandIconColumnIndex: 0 + expandIconColumnIndex: 0, + showHeader: true }; }, @@ -366,7 +369,7 @@ var Table = _react2['default'].createClass({ className += ' ' + prefixCls + '-columns-paging'; } var headerTable = undefined; - var thead = _react2['default'].createElement( + var thead = props.showHeader ? _react2['default'].createElement( 'thead', { className: prefixCls + '-thead' }, _react2['default'].createElement( @@ -374,7 +377,7 @@ var Table = _react2['default'].createClass({ null, columns ) - ); + ) : null; if (props.useFixedHeader) { headerTable = _react2['default'].createElement( 'div', @@ -404,7 +407,20 @@ var Table = _react2['default'].createClass({ 'tbody', { className: prefixCls + '-tbody' }, rows - ) + ), + props.footer ? _react2['default'].createElement( + 'tfoot', + { className: prefixCls + '-tfoot' }, + _react2['default'].createElement( + 'tr', + null, + _react2['default'].createElement( + 'td', + { colSpan: '0' }, + props.footer(this.state.data) + ) + ) + ) : null ) ) );