Skip to content

Commit

Permalink
fix click on selection column can not trigger selection if clickToSel…
Browse files Browse the repository at this point in the history
…ect enable
  • Loading branch information
AllenFang committed Jan 31, 2017
1 parent f6384f6 commit 1aaf605
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/TableBody.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class TableBody extends Component {
const disable = unselectable.indexOf(key) !== -1;
const selected = this.props.selectedRowKeys.indexOf(key) !== -1;
const selectRowColumn = isSelectRowDefined && !this.props.selectRow.hideSelectColumn ?
this.renderSelectRowColumn(selected, inputType, disable, CustomComponent, r) : null;
this.renderSelectRowColumn(selected, inputType, disable, CustomComponent, r, data) : null;
// add by bluespring for className customize
let trClassName = this.props.trClassName;
if (isFun(this.props.trClassName)) {
Expand Down Expand Up @@ -276,9 +276,21 @@ class TableBody extends Component {
}
}

renderSelectRowColumn(selected, inputType, disabled, CustomComponent = null, rowIndex = null) {
handleClickonSelectColumn = (e, isSelect, rowIndex, row) => {
e.stopPropagation();
if (e.target.tagName === 'TD' && this.props.selectRow.clickToSelect) {
const unselectable = this.props.selectRow.unselectable || [];
if (unselectable.indexOf(row[this.props.keyField]) === -1) {
this.handleSelectRow(rowIndex + 1, isSelect, e);
}
}
}

renderSelectRowColumn(selected, inputType, disabled, CustomComponent = null, rowIndex = null, row) {
return (
<td onClick={ e => e.stopPropagation() } style={ { textAlign: 'center' } }>
<td onClick={ e => {
this.handleClickonSelectColumn(e, !selected, rowIndex, row);
} } style={ { textAlign: 'center' } }>
{ CustomComponent ?
<CustomComponent type={ inputType } checked={ selected } disabled={ disabled }
rowIndex={ rowIndex }
Expand Down

0 comments on commit 1aaf605

Please sign in to comment.