diff --git a/src/TableBody.js b/src/TableBody.js index 092860fc0..875fedfd0 100644 --- a/src/TableBody.js +++ b/src/TableBody.js @@ -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)) { @@ -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 ( - e.stopPropagation() } style={ { textAlign: 'center' } }> + { + this.handleClickonSelectColumn(e, !selected, rowIndex, row); + } } style={ { textAlign: 'center' } }> { CustomComponent ?