Skip to content
Closed
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ var table = React.render(
<th>false</th>
<td>whether render expandIcon as a cell</td>
</tr>
<tr>
<td>expandIconColumnHeader</td>
<td>Boolean</td>
<th>true</th>
<td>whether render expandIcon column header. If not and expandIconAsCell is true, second column header will span first column header.</td>
</tr>
<tr>
<td>rowKey</td>
<td>Function(recode,index):string</td>
Expand Down
16 changes: 12 additions & 4 deletions src/Table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const Table = React.createClass({
propTypes: {
data: React.PropTypes.array,
expandIconAsCell: React.PropTypes.bool,
expandIconColumnHeader: React.PropTypes.bool,
expandedRowKeys: React.PropTypes.array,
defaultExpandedRowKeys: React.PropTypes.array,
useFixedHeader: React.PropTypes.bool,
Expand All @@ -25,6 +26,7 @@ const Table = React.createClass({
data: [],
useFixedHeader: false,
expandIconAsCell: false,
expandIconColumnHeader: true,
columns: [],
defaultExpandedRowKeys: [],
rowKey(o) {
Expand Down Expand Up @@ -108,17 +110,23 @@ const Table = React.createClass({

getThs() {
let ths = [];
if (this.props.expandIconAsCell) {
if (this.props.expandIconAsCell && this.props.expandIconColumnHeader) {
ths.push({
key: 'rc-table-expandIconAsCell',
className: `${this.props.prefixCls}-expand-icon-th`,
title: '',
});
}
ths = ths.concat(this.props.columns);
return ths.map((c)=> {
if (c.colSpan !== 0) {
return <th key={c.key} colSpan={c.colSpan} className={c.className || ''}>{c.title}</th>;
return ths.map((c, index) => {
let colSpan = c.colSpan;
if (colSpan !== 0) {
if (this.props.expandIconAsCell && !this.props.expandIconColumnHeader && index === 0) {
// if expand icon is rendered as icon and expandIconColumnHeader is false, we need to span second column header
colSpan = colSpan || 1;
colSpan += 1;
}
return <th key={c.key} colSpan={colSpan} className={c.className || ''}>{c.title}</th>;
}
});
},
Expand Down