Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions src/Table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)));
Expand All @@ -171,6 +172,13 @@ const Table = React.createClass({
return <colgroup>{cols}</colgroup>;
},

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;
Expand Down Expand Up @@ -210,13 +218,6 @@ const Table = React.createClass({
</div>
);
},

isRowExpanded(record) {
const info = this.state.expandedRows.filter((i) => {
return i.record === record;
});
return info[0] && info[0].expanded;
},
});

export default Table;