diff --git a/src/Table.jsx b/src/Table.jsx index a60f4945c..26a188fd5 100644 --- a/src/Table.jsx +++ b/src/Table.jsx @@ -124,8 +124,9 @@ const Table = React.createClass({ const record = data[i]; const key = keyFn ? keyFn(record, i) : undefined; const childrenColumn = record[childrenColumnName]; + const isRowExpanded = this.isRowExpanded(record); let expandedRowContent; - if (expandedRowRender) { + if (expandedRowRender && isRowExpanded) { expandedRowContent = expandedRowRender(record, i); } const className = rowClassName(record, i); @@ -138,13 +139,13 @@ const Table = React.createClass({ visible={visible} onExpand={this.onExpanded} expandable={childrenColumn || expandedRowContent} - expanded={this.isRowExpanded(record)} + expanded={isRowExpanded} prefixCls={`${props.prefixCls}-row`} childrenColumnName={childrenColumnName} columns={columns} key={key}/>); - const subVisible = visible && this.isRowExpanded(record); + const subVisible = visible && isRowExpanded; if (expandedRowContent) { rst.push(this.getExpandedRow(key, expandedRowContent, subVisible, expandedRowClassName(record, i))); @@ -171,6 +172,13 @@ const Table = React.createClass({ return {cols}; }, + isRowExpanded(record) { + const info = this.state.expandedRows.filter((i) => { + return i.record === record; + }); + return info[0] && info[0].expanded; + }, + render() { const props = this.props; const prefixCls = props.prefixCls; @@ -210,13 +218,6 @@ const Table = React.createClass({ ); }, - - isRowExpanded(record) { - const info = this.state.expandedRows.filter((i) => { - return i.record === record; - }); - return info[0] && info[0].expanded; - }, }); export default Table;